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

Version Path
lsd_rails-0.1.6 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1.5 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1.4 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1.3 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1.2 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1.1 Packages/mootools-mobile/Source/Touch/Touchhold.js
lsd_rails-0.1 Packages/mootools-mobile/Source/Touch/Touchhold.js