Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function interactionScreen(){
- if ($(window).width() > 970) {
- do something..
- } else if ($(window).width() < 970) {
- do something..
- }
- }
- interactionScreen();
- $(window).resize(function() {
- interactionScreen();
- });
- var interactionScreen = (function(window) {
- var timer,
- w = $(window);
- return function(executeImmediately) {
- clearTimeout(timer);
- timer = setTimeout(function() {
- var currentWidth = w.width();
- if (currentWidth > 970) {
- console.log("> 970");
- } else {
- console.log("<= 970");
- }
- }, executeImmediately ? 0 : 200);
- };
- }(window));
- interactionScreen(true);
- window.addEventListener("resize", function() {
- interactionScreen();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement