There is a function code that works with the width and scroll level $ (window). It is necessary to call this function either at the moment of scrolling the page, or at the moment of resizing the window.
Tell me, please, how to combine these two events?
Other words need to combine:
$(window).scroll(function(){ /* код функции */ }); $(window).resize(function(){ /* тот же код функции */ });
UPD: Solution
var func = function(e){ /* resize and scroll logic */}; $(window).scroll(func).resize(func);
$(window).scroll(function() { func() }); $(window).resize(function() { func() });
$(window).scroll(function() { func() });
$(window).resize(function() { func() });
- Cypher