jsOMS/UI/Input/Touch/SwipeManager

47 lines
1.2 KiB
Plaintext

/**
* Swipe manager class.
*
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0 * @since 1.0.0
*/
(function (jsOMS, undefined)
{
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Input.Touch');
/**
* @constructor
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
jsOMS.UI.Input.Touch.SwipeManager = function (app)
{
this.app = app;
this.surface = {};
this.activeSwipe = {'startX': null, 'startY': null, 'time': null};
};
jsOMS.UI.Input.Touch.SwipeManager.prototype.add = function (surface, id, cUp, cRight, cDown, cLeft)
{
let e = document.getElementById(surface)
self = this;
e.addEventListener('touchstart', function(event) {
let touch = e.changedTouches[0];
self.activeSwipe.startX = touch.pageX;
self.activeSwipe.startY = touch.pageY;
self.activeSwipe.time = new Date().getTime();
jsOMS.preventAll(event);
});
};
}(window.jsOMS = window.jsOMS || {}));