Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Generated by CoffeeScript 1.9.3
(function() {
$(function() {
var crntPage, direction, divs, getPosition, log, navs, onTouchEnd, onTouchMove, onTouchStart, panels, position;
log = function(x) {
return console.log(x);
};
navs = $('#navs').children();
divs = $('#divs').children();
panels = $('.panel');
crntPage = 0;
navs.each(function(index) {
return $(this).click(function() {
var deg, diff;
log("click");
diff = index - crntPage;
deg = diff > 0 ? 180 : -180;
$(divs[index]).css('transform', 'rotateZ(0deg)');
return setTimeout(function() {
var i, j, ref, ref1;
for (i = j = ref = crntPage, ref1 = index; ref <= ref1 ? j < ref1 : j > ref1; i = ref <= ref1 ? ++j : --j) {
$(divs[i]).css('transform', "rotateZ(" + deg + "deg)");
}
return crntPage = index;
}, 100);
});
});
position = 0;
direction = '';
getPosition = function(event) {
return event.originalEvent.pageX;
};
onTouchStart = function(event) {
return position = getPosition(event);
};
onTouchMove = function(event) {
var move;
move = position - getPosition(event);
$(this).css('transform', "rotateZ(" + move + "deg)");
if (move > 100) {
return direction = 'left';
} else if (move < -100) {
return direction = 'right';
}
};
onTouchEnd = function(event) {
return log("end");
};
divs.each(function(index) {
$(this).on('touchstart mousedown', onTouchStart);
$(this).on('touchmove mousemove', onTouchMove);
return $(this).on('touchend mouseup', onTouchEnd);
});
return log("end");
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.