From c34a8956e1cd07498457f3211898e8de6d794de3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 7 Mar 2015 23:59:27 +0100 Subject: implement swipe gestures on mobile to go to next and previous articles --- themes/_global/js/keyboard.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'themes/_global/js/keyboard.js') diff --git a/themes/_global/js/keyboard.js b/themes/_global/js/keyboard.js index 26978cb2..ec20d3f2 100644 --- a/themes/_global/js/keyboard.js +++ b/themes/_global/js/keyboard.js @@ -1,27 +1,27 @@ function navigateKeyboard(leftURL, rightURL) { window.addEventListener("keypress", function (event) { var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions - console.log("key pressed : " + key); switch (key) { case 37: - // left arrow - if (leftURL != "?view=view&id=") { - window.location = window.location.origin + window.location.pathname + leftURL; - } + goLeft(leftURL); break; - /* - case 38: - // top arrow - window.location = window.location.origin + window.location.pathname + window.location.search + "#top"; - break; - */ + case 39: - //right arrow - if (rightURL != "?view=view&id=") { - window.location = window.location.origin + window.location.pathname + rightURL; - } + goRight(rightURL); break; } }, false); +} + +function goLeft(leftURL) { + if (leftURL != "?view=view&id=") { + window.location = window.location.origin + window.location.pathname + leftURL; + } +} + +function goRight(rightURL) { + if (rightURL != "?view=view&id=") { + window.location = window.location.origin + window.location.pathname + rightURL; + } } \ No newline at end of file -- cgit v1.2.3