I have a variable size and a function that depends on it. As the variable depends on the screen width and if the width changes, then I'll have to place it inside the window resize event. However I want to call it with other events like column events.
$ (window). Reset (if ($ (window) Width ()> 1200) {var size = "big";} else {var size = "small";} show show (param) {if (size == " (".") {$ (". Result.hidden"). Piece (0, 3) .removeClass ('hidden') .Every (some function);} Otherwise if (size == "small") {$ (". Result.hidden "). Piece (0, 2) .removeClass ('hidden'). Each (some function);}}}); $ (Window) .scroll (function () {if ($ (window) .scrollTop () + $ (window) .height () & gt; $ (document) .height () - 50) {showRow ();} });
You can do this, showRow
a global look And the size of the window is in it, so that you can say it inside the shape and to scroll. It seems that you wanted to use showRow
inside your shape if you do not have any other code inside the resize, you can completely delete it in the first example
var showRow = function () {if ($ (window). Width () & gt; 1200) {var size = "big"; } And {var size = "small"; } If (size == "big") {$ ("result." Piece (0, 3) .removeClass ('hidden'). Each (some function); } And if (size == "small") {$ (".ultult.hidden"). Piece (0, 2) .removeClass ('hidden'). Each (some function); }} $ (Window). Reset (function () {showRow (); // other code}); $ (Window) .scroll (function () {if ($ (window) .scrollTop () + $ (window) .height () & gt; $ (document) .height () - 50) {showRow ();} });
If you do not want to use showRow
inside resizing, then start
// window in the SessionVir window Season = $ (Window) Wide ()> 1200? "Bigger"; Var showRow = function () {if (windowSize == "big") {$ ("Result.hidden"). Piece (0, 3) .removeClass ('hidden'). Each (some function); } And if (windowSize == "small") {$ (".ultult.hidden"). Piece (0, 2) .removeClass ('hidden'). Each (some function); }} $ (Window). Resize (function () {if ($ (window). Width ()> 1200) {windowSize = "big"; else} {windowSize = "small"}} // other code}); $ (Window) .scroll (function () {if ($ (window) .scrollTop () + $ (window) .height () & gt; $ (document) .height () - 50) {showRow ();} });
No comments:
Post a Comment