Created
September 4, 2014 14:57
-
-
Save elrrrrrrr/d00b245c26b55a926a7f to your computer and use it in GitHub Desktop.
原生slide组件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function listenGesture(el) { | |
| // el.on('touchstart', function(e) { | |
| // startX = endX = 0; | |
| // var touch = e.touches[0]; | |
| // startX = touch.pageX; | |
| // }) | |
| // el.on('touchmove', function(e) { | |
| // e.preventDefault(); | |
| // }) | |
| el.on('pan', function(e) { | |
| alert('pa') | |
| }) | |
| // el.on('touchend', function(e) { | |
| // var touch = e.changedTouches[0]; | |
| // endX = touch.pageX; | |
| // if (endX - startX > 20) { | |
| // el.trigger('swipe-right'); | |
| // } else if ( startX - endX > 20) { | |
| // el.trigger('swipe-left'); | |
| // } | |
| // }) | |
| } | |
| function initActive(el) { | |
| var self = el, | |
| points = el.find('.point'), | |
| pointsLength = el.find('.point').length; | |
| $(points[0]).addClass('active'); | |
| el.on('next', function(e) { | |
| var index = el.find('.active').index(); | |
| if(index < pointsLength - 1) { | |
| $(points[index]).removeClass('active').next().addClass('active'); | |
| index+=1; | |
| coursel.find('ul').css({left: -1 * index * 290}) | |
| } | |
| }); | |
| el.on('prev', function(e) { | |
| var index = el.find('.active').index(); | |
| if (index>0) { | |
| $(points[index]).removeClass('active').prev().addClass('active'); | |
| index-=1; | |
| coursel.find('ul').css({left: -1 * index * 290}) | |
| } | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment