Last active
August 29, 2015 14:06
-
-
Save RhinoLu/8e12b9746cb5f2d445e2 to your computer and use it in GitHub Desktop.
browser scroll bar smoothing 平滑
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
| // http://bassta.bg/2013/05/smooth-page-scrolling-with-tweenmax/ | |
| $(function(){ | |
| var $window = $(window); | |
| var scrollTime = 1.2; | |
| var scrollDistance = 170; | |
| $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, | |
| overwrite: 5 | |
| }); | |
| }); | |
| }); |
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
| <script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/ScrollToPlugin.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment