gipasoft

Change resolution event

Nov 25th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var width = w.innerWidth;
  2. var height = w.innerHeight;
  3. setInterval(function () {
  4.     if (w.innerWidth !== width || w.innerHeight !== height) {
  5.         width = w.innerWidth;
  6.         height = w.innerHeight;
  7.         $(w).trigger('resolutionchange');
  8.     }
  9. }, 50);
  10.  
  11. $(w).bind('resolutionchange',
  12.     function () {
  13.         if (width > 1200) {
  14.             ... something ...;
  15.         }
  16.         if (width <= 1200 && width > 992) {
  17.             ... something ...;
  18.         }
  19.         if (width <= 992) {
  20.             ... something ...;
  21.         }
  22.     }
  23. );
Advertisement
Add Comment
Please, Sign In to add comment