Created
September 17, 2014 16:41
-
-
Save garystorey/c8d9dc56c14e980c1e78 to your computer and use it in GitHub Desktop.
instead of if..else to add and remove class, use toggle with logic
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
| /* This */ | |
| if (this.scrollTop > 147) { | |
| wrap.addClass("fix-search"); | |
| } else { | |
| wrap.removeClass("fix-search"); | |
| } | |
| /* Becomes This */ | |
| wrap.toggleClass("fix-search", this.scrollTop > 147); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment