improve swiping logic

This commit is contained in:
r888888888
2014-04-12 14:59:02 -07:00
parent 9314db5183
commit 26f35b551c
3 changed files with 24 additions and 16 deletions

View File

@@ -11,17 +11,21 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<script type="text/javascript">
$(function() {
$(document).on("swipeleft", function() {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
$(document).on("swipeleft", function(e) {
if (e.gesture.distance > 240) {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
}
}
});
$(document).on("swiperight", function() {
var href = $(".paginator a[rel=prev]").attr("href");
if (href) {
window.location = href;
$(document).on("swiperight", function(e) {
if (e.gesture.distance > 240) {
var href = $(".paginator a[rel=prev]").attr("href");
if (href) {
window.location = href;
}
}
})
});

View File

@@ -13,15 +13,19 @@
<meta name="viewport" content="width=device-width,initial-scale=<%= @post.device_scale %>">
<script type="text/javascript">
$(function() {
$(document).on("swipeleft", function() {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
$(document).on("swipeleft", function(e) {
if (e.gesture.distance > 240) {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
}
}
});
$(document).on("swiperight", function() {
window.history.back();
$(document).on("swiperight", function(e) {
if (e.gesture.distance > 240) {
window.history.back();
}
})
});
</script>