Skip to content

Instantly share code, notes, and snippets.

@alegut
Created July 4, 2018 06:50
Show Gist options
  • Select an option

  • Save alegut/76a39e73071348f6aeb5bb433c0fdd94 to your computer and use it in GitHub Desktop.

Select an option

Save alegut/76a39e73071348f6aeb5bb433c0fdd94 to your computer and use it in GitHub Desktop.
Jquery long scroll
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