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实现-仅用递归函数和栈操作逆序一个栈... 前言: 因为JAVA和JS语言特性的不同,有些东西在JAVA中可能需要一些技巧和手段才能实现的复杂程序,但是在JS中可能就是天然存在的,所以这套书里面的题目...
5种JavaScript编码规范,你喜欢哪一个? 无论你是刚刚学习 JavaScript,还是正在准备大厂的前端面试,下面这 5 种 JavaScript 编码规范都值得你留意和参考。 什么是编码规范 ...
区块链时代的黑产致富经 不知道说啥的前言 1982年,有着当代焦裕禄称号的徐启斌先生在四川眉山县吼出的“要想富,先修路”这一口号,深深映入我们脑海。落后的交通阻碍了当地资源优势转化...
Errors on the World’s Top 100 Websites and H... When you think of the top 100 sites in the world, you think of high-traffic d...
Using _every inside _&pe... I'm working on javascript-koans, the first challenge of AboutApplyingWhatWeHaveL...