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阅读原文】。感谢您的支持!