Created
July 4, 2018 06:50
-
-
Save alegut/76a39e73071348f6aeb5bb433c0fdd94 to your computer and use it in GitHub Desktop.
Jquery long scroll
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
| wp_enqueue_script('TweenMax', get_stylesheet_directory_uri() . '/assets/plugin/TweenMax.min.js'); | |
| wp_enqueue_script('ScrollToPlugin', get_stylesheet_directory_uri() . '/assets/plugin/ScrollToPlugin.js'); | |
| $(function(){ | |
| var $window = $(window); //Window object | |
| var scrollTime = 1.4; //Scroll time | |
| var scrollDistance = 370; //Distance. Use smaller value for shorter scroll and greater value for longer scroll | |
| $window.on("mousewheel DOMMouseScroll", function(event){ | |
| event.preventDefault(); | |
| var delta = event.originalEvent.wheelDelta/120 || -event.originalEvent.detail/3; | |
| var scrollTop = $window.scrollTop(); | |
| var finalScroll = scrollTop - parseInt(delta*scrollDistance); | |
| TweenMax.to($window, scrollTime, { | |
| scrollTo : { y: finalScroll, autoKill:true }, | |
| ease: Power1.easeOut, //For more easing functions see | |
| autoKill: true, | |
| overwrite: 5 | |
| }); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment