Hi I was wondering how I would need to change this jQuery to make it NOT scroll to the top after reaching the bottom of the web page. Right now you get to the bottom and if you scroll down again it goes back to the top. How do I make it not do that and just stay at the bottom unless the user scrolls upwards?
<script>
(function($){
$(window).on("load",function(){
if(!$(document).data("mPS2id")){
console.log("Error: 'Page scroll to id' plugin not present or activated. Please run the code after plugin is loaded.");
return;
}
$(document).data("mPS2idExtend",{
selector:"._mPS2id-h",
currentSelector:function(){
return this.index($(".mPS2id-highlight-first").length ? $(".mPS2id-highlight-first") : $(".mPS2id-highlight"));
},
input:{y:null,x:null},
i:null,
time:null
}).on("scrollSection",function(e,dlt,i){
var d=$(this).data("mPS2idExtend"),
sel=$(d.selector);
if(!$("html,body").is(":animated")){
if(!i) i=d.currentSelector.call(sel);
if(!(i===0 && dlt>0) && !(i===sel.length-1 && dlt<0)) sel.eq(i-dlt).trigger("click.mPS2id");
}
}).on("keydown",function(e){ //keyboard
var code=e.keyCode ? e.keyCode : e.which,
keys=$(this).data("mPS2id").layout==="horizontal" ? [37,39] : [38,40];
if(code===keys[0] || code===keys[1]){
if($($(this).data("mPS2idExtend").selector).length) e.preventDefault();
$(this).trigger("scrollSection",(code===keys[0] ? 1 : -1));
}
});
//mousewheel (https://github.com/jquery/jquery/issues/2871)
var supportsWheel=false;
function wheel(e){
if (e.type == "wheel") supportsWheel = true;
else if (supportsWheel) return;
if($($(document).data("mPS2idExtend").selector).length) e.preventDefault();
$(document).trigger("scrollSection",((e.detail<0 || e.wheelDelta>0 || e.deltaY < 0 || e.deltaX < 0) ? 1 : -1));
};
document.addEventListener('wheel', wheel, {passive: false}, false);
document.addEventListener('mousewheel', wheel, {passive: false}, false);
document.addEventListener('DOMMouseScroll', wheel, {passive: false}, false);
});
})(jQuery);
</script>
Aucun commentaire:
Enregistrer un commentaire