Sha256: f7deabaccc5c86b8bc893fbb7062127eac2e5ae8782d45443a26c1d5b36f5905
Contents?: true
Size: 963 Bytes
Versions: 7
Compression:
Stored size: 963 Bytes
Contents
/* --- name: Touchhold description: Provides a custom touchhold event for touch devices authors: Christoph Pojer (@cpojer) license: MIT-style license. requires: [Core/Element.Event, Custom-Event/Element.defineCustomEvent, Browser.Features.Touch] provides: Touchhold ... */ (function(){ var name = 'touchhold', delayKey = name + ':delay', disabled, timer; var clear = function(e){ clearTimeout(timer); }; var events = { touchstart: function(event){ if (event.touches.length > 1){ clear(); return; } timer = (function(){ this.fireEvent(name, event); }).delay(this.retrieve(delayKey) || 750, this); }, touchmove: clear, touchcancel: clear, touchend: clear }; Element.defineCustomEvent(name, { onSetup: function(){ this.addEvents(events); }, onTeardown: function(){ this.removeEvents(events); }, onEnable: function(){ disabled = false; }, onDisable: function(){ disabled = true; clear(); } }); })();
Version data entries
7 entries across 7 versions & 1 rubygems