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

@@ -9,12 +9,12 @@ body {
} }
input[type=text], input[type=submit] { input[type=text], input[type=submit] {
font-size: 20pt; font-size: 18pt;
} }
/* paginator */ /* paginator */
div.paginator { div.paginator {
font-size: 18pt; font-size: 16pt;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;

View File

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

View File

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