Template:Team:HokkaidoU Japan/JS
From 2014.igem.org
(Difference between revisions)
Line 276: | Line 276: | ||
$(this).unbind( touchMoveEvent, moveHandler); | $(this).unbind( touchMoveEvent, moveHandler); | ||
// if start and stop contain data figure out if we have a swipe event | // if start and stop contain data figure out if we have a swipe event | ||
- | if ( start | + | if ( start ){if (stop ) { |
// calculate the distance between start and stop data | // calculate the distance between start and stop data | ||
var deltaX = Math.abs(start.coords[0] - stop.coords[0]), | var deltaX = Math.abs(start.coords[0] - stop.coords[0]), | ||
deltaY = Math.abs(start.coords[1] - stop.coords[1]), | deltaY = Math.abs(start.coords[1] - stop.coords[1]), | ||
- | distance = Math.sqrt(deltaX*deltaX+deltaY*deltaY); | + | distance = Math.sqrt(deltaX*deltaX+deltaY*deltaY);} |
// check if the delay and distance are matched | // check if the delay and distance are matched | ||
- | if ( stop.time - start.time < swipe.delay | + | if ( stop.time - start.time < swipe.delay ) {if (distance >= swipe.min ) { |
var events = ['swipe']; | var events = ['swipe']; | ||
// check if we moved horizontally | // check if we moved horizontally | ||
- | if( deltaX >= swipe.min | + | if( deltaX >= swipe.min ) { if (deltaY < swipe.min) { |
// based on the x coordinate check if we moved left or right | // based on the x coordinate check if we moved left or right | ||
events.push( start.coords[0] > stop.coords[0] ? "swipeleft" : "swiperight" ); | events.push( start.coords[0] > stop.coords[0] ? "swipeleft" : "swiperight" ); | ||
- | } else | + | }} else |
// check if we moved vertically | // check if we moved vertically | ||
- | if(deltaY >= swipe.min | + | if(deltaY >= swipe.min) {if (deltaX < swipe.min){ |
// based on the y coordinate check if we moved up or down | // based on the y coordinate check if we moved up or down | ||
events.push( start.coords[1] < stop.coords[1] ? "swipedown" : "swipeup" ); | events.push( start.coords[1] < stop.coords[1] ? "swipedown" : "swipeup" ); | ||
- | } | + | }} |
+ | } | ||
// trigger swipe events on this guy | // trigger swipe events on this guy | ||
Line 510: | Line 511: | ||
this.current = page; | this.current = page; | ||
} | } | ||
- | else if ( dir === 'next' | + | else if ( dir === 'next' ){if{this.options.direction === 'ltr' || dir === 'prev' && this.options.direction === 'rtl' ) { |
- | if ( !this.options.circular | + | if ( !this.options.circular){if( this.current === this.itemsCount - 1 ) { |
this.end = true; | this.end = true; | ||
- | } | + | }} |
else { | else { | ||
this.previous = this.current; | this.previous = this.current; | ||
this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0; | this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0; | ||
} | } | ||
- | } | + | }} |
- | else if ( dir === 'prev' | + | else if ( dir === 'prev' ({if( this.options.direction === 'ltr' || dir === 'next' && this.options.direction === 'rtl' ) { |
- | if ( !this.options.circular | + | if ( !this.options.circular){if( this.current === 0 ) { |
this.end = true; | this.end = true; | ||
- | } | + | }} |
else { | else { | ||
this.previous = this.current; | this.previous = this.current; | ||
this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1; | this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1; | ||
} | } | ||
- | } | + | }} |
this.$nextItem = !this.options.circular && this.end ? this.$current : this.$items.eq( this.current ); | this.$nextItem = !this.options.circular && this.end ? this.$current : this.$items.eq( this.current ); | ||
Line 587: | Line 588: | ||
// overlays | // overlays | ||
- | if (this.options.shadows | + | if (this.options.shadows) {if (!this.end) { |
var o_left_style = (dir === 'next') ? { | var o_left_style = (dir === 'next') ? { | ||
Line 619: | Line 620: | ||
$o_right.css(o_right_style); | $o_right.css(o_right_style); | ||
- | } | + | }} |
setTimeout( function() { | setTimeout( function() { | ||
Line 626: | Line 627: | ||
// overlays | // overlays | ||
- | if ( self.options.shadows | + | if ( self.options.shadows) { if(!self.end ) { |
$o_middle_f.css({ | $o_middle_f.css({ | ||
Line 644: | Line 645: | ||
}); | }); | ||
- | } | + | }} |
}, 25 ); | }, 25 ); | ||
}, | }, |
Revision as of 17:06, 13 September 2014