悬停时垂直滚动而不是单击? jQuery API
我正在使用 jQuery scrollTo 滚动溢出的 div 中的内容。当我单击链接时,div 将垂直滚动其内容。但是,我希望当我将鼠标悬停在链接上而不是单击它们时发生这种效果。
我不相信这是 jQuery 的scrollTo 的一个选项。但是,有一个用于 hover
事件的 jQuery API 方法。
这似乎是一个简单的问题,但是有没有办法通过悬停而不是单击来维护“scrollTo”的垂直滚动功能?
垂直滚动:
jQuery(function ($) {
$.localScroll.defaults.axis = 'y';
$.localScroll({
target: '#content',
// could be a selector or a jQuery object too.
queue: true,
duration: 500,
hash: false,
onBefore: function (e, anchor, $target) {
// The 'this' is the settings object, can be modified
},
onAfter: function (anchor, settings) {
// The 'this' contains the scrolled element (#content)
}
});
});
悬停:
$("#page-wrap li.button").hover(function(){ /* vertically slide here? */ });V
I am using jQuery scrollTo to scroll contents within a div that is overflown. When I click the links, the div will vertically scroll its contents. However, I would like this effect to occur when I hover over the links, instead of click them.
I don't believe this is an option with jQuery's scrollTo. However, there is a jQuery API method for hover
event.
This may seem like a simply question, but is there a way to maintain my vertical scrolling functionality of "scrollTo" by hovering over instead of clicking?
Vertical scroll:
jQuery(function ($) {
$.localScroll.defaults.axis = 'y';
$.localScroll({
target: '#content',
// could be a selector or a jQuery object too.
queue: true,
duration: 500,
hash: false,
onBefore: function (e, anchor, $target) {
// The 'this' is the settings object, can be modified
},
onAfter: function (anchor, settings) {
// The 'this' contains the scrolled element (#content)
}
});
});
Hovering:
$("#page-wrap li.button").hover(function(){ /* vertically slide here? */ });V
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用scrollTo插件平滑滚动:
这将向下滚动。制作向上滚动按钮
小提琴示例更简单: http://jsfiddle.net/8Nkpr/1/
Smooth scrolling with scrollTo plugin:
This will scroll down. It's simpler to make the scroll up button
fiddle example: http://jsfiddle.net/8Nkpr/1/