提交 04792447 编写于 作者: C Catouse

* carousel support touch event on mobile phones.

上级 80c97e39
此差异已折叠。
......@@ -42,6 +42,41 @@
interval: 5000
, pause: 'hover'
, wrap: true
, touchable: true
}
Carousel.prototype.touchable = function()
{
if(!this.options.touchable) return;
this.$element.on('touchstart touchmove touchend', $.proxy(touch,this));
/* listen the touch event */
function touch(event)
{
var event = event || window.event;
if(event.originalEvent) event = event.originalEvent;
switch(event.type)
{
case "touchstart":
this.touchStart = event.touches[0];
break;
case "touchend":
handleCarousel(this.$element, event.changedTouches[0].pageX - this.touchStart.pageX);
break;
}
event.preventDefault();
}
function handleCarousel(carousel, this, distance)
{
if(carousel.length < 1) return;
if(distance > 10) carousel.find('.left.carousel-control').click();
if(distance < -10) carousel.find('.right.carousel-control').click();
}
}
Carousel.prototype.cycle = function (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册