[英]How to make a div act as a scrollbar handle
I'm trying to make a highly customized 'scrollbar' (more like a navbar that scrolls) for my application, but I can't find any plugins that fit my needs. 我正在尝试为我的应用程序制作一个高度自定义的“滚动条”(更像是滚动的导航栏),但我找不到任何符合我需求的插件。
My questions are: 我的问题是:
window
scroll once the red div
is translated? 这里调用了什么函数,一旦红色div
被翻译, window
滚动? (is it $.scrollTop()
, if so, how do I animate that?) (是$.scrollTop()
,如果是这样,我该如何设置动画?) I've seen IScroll , but it's no longer supported as of ~2 years and lacks mouse wheel easing and bounce. 我见过IScroll ,但它已经不再支持〜2年了,并且没有鼠标滚轮缓和和反弹。 Am I missing something? 我错过了什么吗? Thanks for the help! 谢谢您的帮助!
Edit : Turns out it is $.scrollTop
for the first question. 编辑 :对于第一个问题,结果是$.scrollTop
。
Try this, seems like what you were looking for: 尝试这个,看起来像你在寻找:
http://codepen.io/blyk/pen/JGtfd http://codepen.io/blyk/pen/JGtfd
$(document).ready(function(){
$("div").mouseenter(function(){
var id = $(this).attr('id');
$('a').removeClass('active');
$("[href=#"+id+"]").addClass('active');
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.