From 97712b51220aa69dfbe745d4605de02e42711eb4 Mon Sep 17 00:00:00 2001 From: franzz Date: Sat, 1 Jun 2019 14:08:20 +0200 Subject: [PATCH] add swipe event catcher --- masks/project.html | 5 +++++ script/spot.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/masks/project.html b/masks/project.html index 0bbbca1..ab1629a 100755 --- a/masks/project.html +++ b/masks/project.html @@ -103,6 +103,11 @@ function initPage(asHash) { //Add "Loading" Post getPost({type: 'loading', headerless: true, formatted_time: '', relative_time: ''}).appendTo($('#loading')); + //Mobile events + $("#feed").onSwipe(function(aiDelta){ + if(aiDelta.x > self.tmp('feed_width')/3 && aiDelta.x > Math.abs(aiDelta.y)) toggleFeedPanel(false); + }); + //project Bootstrap initProject(asHash.items[0]); } diff --git a/script/spot.js b/script/spot.js index 02f6ab2..0a57320 100755 --- a/script/spot.js +++ b/script/spot.js @@ -295,3 +295,18 @@ $.prototype.hoverSwap = function(sDefault, sHover) }) .text(sDefault); }; + +$.prototype.onSwipe = function(fCallBack){ + return $(this) + .on('mousedown touchstart', function(e) { + var $This = $(this); + $This.data('x-down', e.pageX); + $This.data('y-down', e.pageY); + }) + .on('mouseup touchend',function (e) { + var $This = $(this); + var iDeltaX = e.pageX - $This.data('x-down'); + var iDeltaY = e.pageY - $This.data('y-down'); + fCallBack({x:iDeltaX, y:iDeltaY}); + }); +};