Skip to content

Instantly share code, notes, and snippets.

@moxuse
Created October 11, 2013 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxuse/6928867 to your computer and use it in GitHub Desktop.
Save moxuse/6928867 to your computer and use it in GitHub Desktop.
this.car_select = $("#swipe-section").children("img");
$('#carSelect').hammer({
prevent_default: true,
drag_vertical: true,
release: true
})
.on('drag dragend', function (ev) {
if (!self.isAnimating) {
var gest = ev.gesture;
switch (ev.type) {
case 'drag':
var nextPosY = -1 + gest.deltaY * 2.0;
self.car_select.css('-webkit-transition: 0s');
self.car_select.css('-webkit-transform','translate(0px,' + nextPosY + 'px)');
break;
case 'dragend':
if (self.dragThreshould < gest.deltaY && 0 < self.currentId) {
self.currentId -= 1;
} else if (-self.dragThreshould > gest.deltaY && 3 > self.currentId) {
self.currentId += 1;
} else {
self.currentId = self.currentId;
}
var nextPosY = -1 * (self.currentId * self.pageHeight);
self.car_select.css('-webkit-transition: 1s ease-out');
self.car_select.css('-webkit-transform','translate(0px,' + nextPosY + 'px)');
console.log("drugended..._ :", self.currentId);
break;
default:
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment