Reputation: 39
I tried to build a custom scroll for my website but it's not perfect and I don't know how to improve it. It should scroll from one position to another specific position but there is a difference of pixels that become bigger every scroll events. It also seems to not work on chrome.
here is a link to the html file :http://infographie.inraci.be/blc/blc.html
here is the code :
$(window).bind('mousewheel DOMMouseScroll', function(event){
var hauteur5 = $(window).height();
var scroll5 = $(window).scrollTop();
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
$(window).scrollTo(scroll5-hauteur5/4,1,function(){
})
} else {
$(window).scrollTo(scroll5+hauteur5/4,1,function(){
})
}
});
Upvotes: 0
Views: 1224
Reputation: 528
If you want check this snippet: https://stackoverflow.com/a/38572744/3605379
There I check the week speed with a timeout. Play with it so you can get the timing right.
Upvotes: 1