UNPKG

parrot-layout

Version:
29 lines (28 loc) 905 B
"use strict"; if (!self.window.hasOwnProperty('swipeEventsPolyfill')) { var SWIPE_TRESHOLD_1 = 120; var originX_1; self.window.addEventListener('mousedown', function (e) { originX_1 = e.pageX; }); self.window.addEventListener('mousemove', function (e) { if (originX_1 === null) { return; } var diff = e.pageX - originX_1; if (diff > SWIPE_TRESHOLD_1) { document.body.dispatchEvent(new Event('swipe-right')); originX_1 += SWIPE_TRESHOLD_1; } else if (diff < -SWIPE_TRESHOLD_1) { document.body.dispatchEvent(new Event('swipe-left')); originX_1 -= SWIPE_TRESHOLD_1; } }); self.window.addEventListener('mouseup', function (e) { originX_1 = null; }); Object.defineProperty(self.window, 'swipeEventsPolyfill', { value: true, }); }