Sha256: 3ea8331453f6ad1a351f83938fc2cbeb545baaa4aa3f8d0036e1f119c9156df4
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
Harpiya.ready(function($) { Harpiya.addSwipeEventListeners = function($carousel) { var touchStartX = 0 var touchStartY = 0 var touchCurrentX = 0 var touchCurrentY = 0 var SWIPE_THRESHOLD = 40 $carousel.on('touchstart.bs.carousel', function(event) { touchStartX = event.touches[0].clientX touchStartY = event.touches[0].clientY }) $carousel.on('touchmove.bs.carousel', function(event) { touchCurrentX = event.touches[0].clientX touchCurrentY = event.touches[0].clientY }) $carousel.on('touchend.bs.carousel', function(_event) { var carouselInstance = $carousel.data('bs.carousel') var touchDeltaX = touchCurrentX - touchStartX var touchDeltaY = touchCurrentY - touchStartY var absDeltaX = Math.abs(touchDeltaX) var absDeltaY = Math.abs(touchDeltaY) if (touchCurrentX > 0 && absDeltaX > SWIPE_THRESHOLD && absDeltaX > absDeltaY) { var direction = absDeltaX / touchDeltaX if (direction > 0) { carouselInstance.prev() } if (direction < 0) { carouselInstance.next() } } touchCurrentX = 0 touchStartX = 0 touchCurrentY = 0 touchStartY = 0 carouselInstance.touchDeltaX = 0 }) } $('.carousel').each(function(_index, carousel) { Harpiya.addSwipeEventListeners($(carousel)) }) })
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
harpiya_frontend-4.3.0.alpha | app/assets/javascripts/harpiya/frontend/views/harpiya/shared/carousel/swipes.js |