gpt4 book ai didi

jquery - 如何更改网页的默认滚动速度、滚动量、滚动惯性

转载 作者:技术小花猫 更新时间:2023-10-29 12:52:05 24 4
gpt4 key购买 nike

我想改变网页的默认滚动速度、数量和惯性。我谷歌了很多,但徒劳无功

幸运的是,后来,这一天,我找到了a plugin这允许我们仅在特定的 div 标记内而不是在整个网页中更改滚动速度、数量、惯性。

这是一个基本代码

    $(".I-WILL-APPLY-ONLY HERE").mCustomScrollbar({
set_width:false,
set_height:false,
horizontalScroll:false,
scrollInertia:550,
SCROLLINERTIA:"easeOutCirc",
mouseWheel:"auto",
autoDraggerLength:true,
scrollButtons:{
enable:false,
scrollType:"continuous",
SCROLLSPEED:20,
SCROLLAMOUNT:40
},
advanced:{
updateOnBrowserResize:true,
updateOnContentResize:false,
autoExpandHorizontalScroll:false,
autoScrollOnFocus:true
},
callbacks:{
onScrollStart:function(){},
onScroll:function(){},
onTotalScroll:function(){},
onTotalScrollBack:function(){},
onTotalScrollOffset:0,
whileScrolling:false,
whileScrollingInterval:30
}
});



<div id="I-WILL-APPLY-ONLY HERE" class="I-WILL-APPLY-ONLY HERE">
A basic height in pixels would be defined for this element and any content appearing here will have a different scrollspeed,inertia.Mentioning heignt of this div element is compulsary,else i wont show the output </div>

问题是我想要整个页面,而不仅仅是一个特定的 div 元素。任何帮助将不胜感激。请帮助我

提前致谢

最佳答案

你可以使用 jQuery 来做到这一点,看看我的 fiddle :http://jsfiddle.net/promatik/NFk2L/

您可以添加滚动事件的事件监听器,请注意您可能会阻止滚动的默认操作...if (event.preventDefault) event.preventDefault();

然后该事件的处理程序将使用 jQuery animate 执行滚动 ...

function handle(delta) {
var time = 1000;
var distance = 300;

$('html, body').stop().animate({
scrollTop: $(window).scrollTop() - (distance * delta)
}, time );
}

您可以设置时间、距离(您还可以添加缓动方法),请参阅 fiddle 中的完整示例

关于jquery - 如何更改网页的默认滚动速度、滚动量、滚动惯性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14426548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com