javascript - Disable a whole function when window size is below 770px -


what disable whole following function when window size below 770px? , enable again when screen size above 770px... can using javascript self?

here whole function / code / snippet need disabled:

//sticky box // $(function () {     $.fn.scrollbottom = function () {         return $(document).height() - this.scrolltop() - this.height();     };      var $stickybox = $('.detailsbox');     var $window = $(window);      $window.bind("scroll resize", function () {         var gap = $window.height() - $stickybox.height() - 10;         var visiblefoot = 255 - $window.scrollbottom();         var scrolltop = $window.scrolltop();          if (scrolltop < 50) {             $stickybox.css({                 top: (130 - scrolltop) + "px",                 bottom: "auto"             });         } else if (visiblefoot > gap - 100) {             $stickybox.css({                 top: "auto",                 bottom: visiblefoot + "px"             });         } else {             $stickybox.css({                 top: 80,                 bottom: "auto"             });         }     }); }); 

you use flag keeptrack of window size (i see you're using jquery, assume loaded):

var smallscreen = false;  $(document).ready(function() {     if($(window).width() < 770) {         smallscreen = true;     } });  $(window).resize(function() {     if($(window).width() < 770) {         smallscreen = true;     } else {         smallscreen = false;     } }); 

and use when call function:

function dosomething() {     if(smallscreen) {         //do stuff here     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -