<commit_before>const DISTANCE_THRESHOLD = 5; // maximum pixels pointer can move before cancel
const TIME_THRESHOLD = 400;   // maximum milliseconds between down and up before cancel

export default function tap ( node, callback ) {
	return new TapHandler( node, callback );
}

function TapHandler ( node, callback ) {
	this.node = node;
	this.callback = callback;

	this.preventMousedownEvents = false;

	this.bind( node );
}

TapHandler.prototype = {
	bind ( node ) {
		// listen for mouse/pointer events...
		if ( window.navigator.pointerEnabled ) {
			node.addEventListener( 'pointerdown', handleMousedown, false );
		} else if ( window.navigator.msPointerEnabled ) {
			node.addEventListener( 'MSPointerDown', handleMousedown, false );
		} else {
			node.addEventListener( 'mousedown', handleMousedown, false );
		}

		// ...and touch events
		node.addEventListener( 'touchstart', handleTouchstart, false );

		// native buttons, and <input type='button'> elements, should fire a tap event
		// when the space key is pressed
		if ( node.tagName === 'BUTTON' || node.type === 'button' ) {
			node.addEventListener( 'focus', handleFocus, false );
		}

		node.__tap_handler__ = this;
	},

	fire ( event, x, y ) {
		this.callback({
			node: this.node,
			original: event,
			x,
			y
		});
	},
<commit_msg>Stop on-tap from firing twice on Windows<commit_after>const DISTANCE_THRESHOLD = 5; // maximum pixels pointer can move before cancel
const TIME_THRESHOLD = 400;   // maximum milliseconds between down and up before cancel

export default function tap ( node, callback ) {
	return new TapHandler( node, callback );
}

function TapHandler ( node, callback ) {
	this.node = node;
	this.callback = callback;

	this.preventMousedownEvents = false;

	this.bind( node );
}

TapHandler.prototype = {
	bind ( node ) {
		if ('ontouchstart' in window) {
			// ...and touch events
			node.addEventListener("touchstart", handleTouchstart, false);
		} else {
			// listen for mouse/pointer events...
			if (window.navigator.pointerEnabled) {
				node.addEventListener("pointerdown", handleMousedown, false);
			} else if (window.navigator.msPointerEnabled) {
				node.addEventListener("MSPointerDown", handleMousedown, false);
			} else {
				node.addEventListener("mousedown", handleMousedown, false);
			}
		}
		
		// native buttons, and <input type='button'> elements, should fire a tap event
		// when the space key is pressed
		if ( node.tagName === 'BUTTON' || node.type === 'button' ) {
			node.addEventListener( 'focus', handleFocus, false );
		}

		node.__tap_handler__ = this;
	},

	fire ( event, x, y ) {
		this.callback({
			node: this.node,
			original: event,
			x,
			y
		});
	},

{'fraction_non_alphanumeric': 0.12402234636871508, 'fraction_numerical': 0.0029795158286778397, 'mean_word_length': 3.6151202749140894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1430047', 'n_tokens_mistral': 916, 'n_tokens_neox': 802, 'n_words': 237}