本文介绍了如何使用jQuery在div中拖动和滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经环顾了一段时间,但找不到结合这些元素的方法:

I've been looking around for some time now, but I can't find a way to combine these elements:

我想要100%宽度的div,并带有1行元素.我需要滚动浏览该div,就像: http://jqueryfordesigners.com/demo/scrollable- timelines.html

I want a 100% width div, with 1 row of elements. I need to scroll through this div, just like: http://jqueryfordesigners.com/demo/scrollable-timelines.html

所以有隐藏的溢出等等.

So with a hidden overflow and such.

但是,现在我希望在放开鼠标单击时获得某种程度的平滑,因此就像扫一扫一样.因此,当我从左向右拖动屏幕并放开鼠标时,它将继续运行1秒钟,并且线性降低.嗯,我说得通吗?

But now I want some sort of smooth ease when I let go of the mouseclick, so it'll be like a sort sweep. So when I drag the screen from left to right, and let go of the mouse, it'll move on for 1 sec and linearly slowing down. Hm, am I making sense?

有人知道让我重回正轨的任何脚本或提示吗?

Does anyone know of any scripts or some tips to put me back on track?

推荐答案

Utterscroll 是我编写的拖放式滚动库:(演示暂时中断,似乎CDN链接不再起作用,)

Utterscroll is a drag and scroll library I've written: ( demo temporarily broken, seems a CDN link no longer works,)

GitHub: https://github.com/debiki/utterscroll
GitHub托管的演示: http://rawgit.com/debiki/utterscroll/master/utterscroll-example.html

GitHub: https://github.com/debiki/utterscroll
GitHub hosted demo: http://rawgit.com/debiki/utterscroll/master/utterscroll-example.html

它与其他库的不同之处在于:1)了解您是否打算选择文本,而不是滚动文本(请注意,在问题所链接的示例,无法选择文本),并且2)不需要或几乎不需要配置.

It differs from other libraries in that it 1) understands if you intend to select text, rather than scrolling (note that in the example linked to by the question, it's not possible to select text), and 2) it needs no, or almost no, configuration.

但是,当您释放鼠标时,Utterscroll会停止(就像上面的答案中的Dragscrollable一样.)

Utterscroll stops when you release the mouse though (just like Dragscrollable, in the answer above, does.)

这篇关于如何使用jQuery在div中拖动和滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 02:17