Which JavaScript-based library can be recommended for a carousel-like swipe experience?

综合编程 2018-07-23 阅读原文

I'd like to create a carousel-like swipe experience for mobile touch devices based on JavaScript for iOS, Android and WP8 that's easy to use and fulfills all my requirements.

So far I tried these plugins but none of them really convinced me:

  • TouchSwipe (Too complicated)
  • SwipeView (Has problems if swiped fast)
  • iScroll (No WP8 support)

Thus I'm looking for a good JS library which can fullfill these requirements:

  • Must be able to swipe all kind of contents, not only images. E.g. I want to be able to pass it an array of

    elements and the plugin should take care of them and make them horizontally swipeable.
  • The plugin must
    work for iOS 4.x+, Android 2.2+ and Windows Phone 8.
  • It should be as small (in terms of kilobytes) and lightweight as possible.
  • It should be performance-optimized. E.g. if I passed 20 div elements with lots of inner content, the library should be smart enough to hide non-visible items and swipe only the divs that matter (the ones that are visible).
  • Swiping should be smooth and if the user releases the screen the swiped element should snap to the borders of the parent element so that only 1 element is visible at a time.

Is there a library which can be recommended?

Problem courtesy of: Timo


Looking at your requirements I can recommend Hammer.js I have used it on a few similar projects and its nice and small only around 3kb minified. Its pretty easy to extended and modify to your exact requirements, as I don't think anything off the shelf will work exactly to what you need.


Also a quick note from experience play around with the default settings to get te right sensitivity and motion range that you want.

Solution courtesy of: Dominic Green

CSS3 Recipes

责编内容by:CSS3 Recipes阅读原文】。感谢您的支持!


JS事件浅析 一个网页由三层组成(html 结构,js 行为,css 表现),一切的东西其实都建立在html上,html里面的dom提供了一些事件,然后通过js封装,我们可以用js去调用dom上的事件。事件有很多,有我用过的有我没用过的,今天我想分析一番...
js中的继承 JS虽然不像是JAVA那种强类型的语言,但也有着与JAVA类型的继承属性,那么JS中的继承是如何实现的呢? 一、构造函数继承 1 在构造函数中,同样属于两个新创建的函数,也是不相等的 2 3 function Fn...
js实现tab选项卡切换 通过原生js实现tab切换,首先讲解一下实现的原理。 1.点击按钮首先给这个被点击的按钮添加一个active类,给点击的改变背景色 2.点击按钮其实就是把相应的div给显示出来。 需要注意的是,点击按钮,给按钮添加了一个类和把对...
「JavaScript」同步、异步、回调执行顺序之经典闭包setTimeout分析... 聊聊同步、异步和回调 同步,异步,回调,我们傻傻分不清楚, 有一天,你找到公司刚来的程序员小T,跟他说:“我们要加个需求,你放下手里的事情优先支持,我会一直等你做完再离开”。小T微笑着答应了,眼角却滑过一丝不易觉察的杀意。 ...
A Reason to Code A few months ago I read about a new programming language called Reason . It was sold to me as a better JavaScript, l...