Skip to content

Commit

Permalink
added swipe support
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent committed Feb 16, 2012
1 parent c5bc803 commit 25629f4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
1 change: 1 addition & 0 deletions web/index.html
Expand Up @@ -61,6 +61,7 @@
<script src="js/jquery.ui.mouse.js"></script>
<script src="js/jquery.ui.slider.js"></script>
<script src="js/jquery.mousewheel.js"></script>
<script src="js/jquery.swipe.js"></script>
<script>
$(document).ready(function(){
$('#coverflow').coverflow({
Expand Down
1 change: 1 addition & 0 deletions web/js/jquery.swipe.js
52 changes: 48 additions & 4 deletions web/js/jquery.ui.coverflow.js
Expand Up @@ -54,6 +54,11 @@
spacing: 100,
keyboard: true,
mousewheel: true,
swipe: true,
minSwipeLength: 65,
minMouseSwipeLength: 100,
preventDefault: false,
includeMouseSwipe: true,
slider: false
},

Expand All @@ -67,10 +72,7 @@
this.itemHeight = this.items.height();
this.duration = o.duration;
this.current = o.item;
this.items.bind(o.trigger, function() {
self.select(this);
});


// Center the actual parent's left side within it's parent
this.element.css(
this.props[2],
Expand Down Expand Up @@ -140,6 +142,48 @@
});
}

// Enabled only if Swipe library present
if (this.options.swipe && $.fn.swipe !== undefined) {
this.items.swipe({
minSwipeLength: this.options.minSwipeLength,
minMouseSwipeLength: this.options.minMouseSwipeLength,
preventDefault: this.options.preventDefault,
includeMouseSwipe: this.options.includeMouseSwipe,
swiped: function (e, ui) {
this.swiped = true;
event.preventDefault();
event.stopPropagation();
var current = self.current;
if (ui.swipeDirection === 'right') {
if (current > 0) {
current--;
self.select(current, true);
}
} else {
if (ui.swipeDirection === 'left') {
if (current < self.element.find(self.options.items).length - 1) {
current++;
self.select(current, true);
}
}
}
}
});
}

// Handle click on items
this.items.bind(o.trigger, function() {
if(this.swiped === true)
{
this.swiped = false;
}
else
{
self.select(this);
}
});


// Enable keyboard navigation
if (this.options.keyboard) {
self.keyboardHandler = function(e) {
Expand Down

0 comments on commit 25629f4

Please sign in to comment.