Last active
January 1, 2016 10:59
-
-
Save handleman/8135376 to your computer and use it in GitHub Desktop.
javascript. Триггер на изменение ширины окна браузера
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isTouch = function() { | |
| return $(window).width() < 980 ? true : false; | |
| }; | |
| var determineScreenClass = function() { | |
| $("html").toggleClass("large-screen", !isTouch()); | |
| }; | |
| // ========== | |
| // = Functions which has to be reinitiated when the window size is changed = | |
| // ========== | |
| var triggeredOnResize = function() { | |
| // do stuff there | |
| }; | |
| // counter in miliseconds | |
| $(window).resize(function() { | |
| determineScreenClass(); | |
| clearTimeout(fromLastResize); | |
| fromLastResize = setTimeout(function() { | |
| triggeredOnResize(); | |
| }, 250); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment