mirror of
https://github.com/VTECRM/vtenext.git
synced 2026-02-27 00:28:47 +00:00
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/*************************************
|
|
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
************************************/
|
|
(function(factory) {
|
|
if (typeof define === 'function' && define.amd) {
|
|
define(['jquery', 'hammerjs'], factory);
|
|
} else if (typeof exports === 'object') {
|
|
factory(require('jquery'), require('hammerjs'));
|
|
} else {
|
|
factory(jQuery, Hammer);
|
|
}
|
|
}(function($, Hammer) {
|
|
function hammerify(el, options) {
|
|
var $el = $(el);
|
|
if(!$el.data("hammer")) {
|
|
$el.data("hammer", new Hammer($el[0], options));
|
|
}
|
|
}
|
|
|
|
$.fn.hammer = function(options) {
|
|
return this.each(function() {
|
|
hammerify(this, options);
|
|
});
|
|
};
|
|
|
|
// extend the emit method to also trigger jQuery events
|
|
Hammer.Manager.prototype.emit = (function(originalEmit) {
|
|
return function(type, data) {
|
|
originalEmit.call(this, type, data);
|
|
$(this.element).trigger({
|
|
type: type,
|
|
gesture: data
|
|
});
|
|
};
|
|
})(Hammer.Manager.prototype.emit);
|
|
})); |