PageSourceSearch

https://anavitraduccion.com/js/jquery.event.move.js

js anavitraduccion.com collected 2026-10-06 09:32:55 UTC 16,208 bytes, 621 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opener = _____WB$wombat$assign$function_____("opener");
10// jquery.event.move
11//
12// 1.3.6
13//
14// Stephen Band
15//
16// Triggers 'movestart', 'move' and 'moveend' events after
17// mousemoves following a mousedown cross a distance threshold,
18// similar to the native 'dragstart', 'drag' and 'dragend' events.
19// Move events are throttled to animation frames. Move event objects
20// have the properties:
21//
22// pageX:
23// pageY:   Page coordinates of pointer.
24// startX:
25// startY:  Page coordinates of pointer at movestart.
26// distX:
27// distY:  Distance the pointer has moved since movestart.
28// deltaX:
29// deltaY:  Distance the finger has moved since last event.
30// velocityX:
31// velocityY:  Average velocity over last few events.
32
33
34(function (thisModule) {
35	if (typeof define === 'function' && define.amd) {
36        // AMD. Register as an anonymous module.
37        define(['jquery'], thisModule);
38    } else if ((typeof module !== "undefined" && module !== null) && module.exports) {
39        module.exports = thisModule;
40	} else {
41		// Browser globals
42        thisModule(jQuery);
43	}
44})(function(jQuery, undefined){
45
46	var // Number of pixels a pressed pointer travels before movestart
47	    // event is fired.
48	    threshold = 6,
49	
50	    add = jQuery.event.add,
51	
52	    remove = jQuery.event.remove,
53
54	    // Just sugar, so we can have arguments in the same order as
55	    // add and remove.
56	    trigger = function(node, type, data) {
57	    	jQuery.event.trigger(type, data, node);
58	    },
59
60	    // Shim for requestAnimationFrame, falling back to timer. See:
61	    // see http://paulirish.com/2011/requestanimationframe-for-smart-animating/
62	    requestFrame = (function(){
63	    	return (
64	    		window.requestAnimationFrame ||
65	    		window.webkitRequestAnimationFrame ||
66	    		window.mozRequestAnimationFrame ||
67	    		window.oRequestAnimationFrame ||
68	    		window.msRequestAnimationFrame ||
69	    		function(fn, element){
70	    			return window.setTimeout(function(){
71	    				fn();
72	    			}, 25);
73	    		}
74	    	);
75	    })(),
76	    
77	    ignoreTags = {
78	    	textarea: true,
79	    	input: true,
80	    	select: true,
81	    	button: true
82	    },
83	    
84	    mouseevents = {
85	    	move: 'mousemove',
86	    	cancel: 'mouseup dragstart',
87	    	end: 'mouseup'
88	    },
89	    
90	    touchevents = {
91	    	move: 'touchmove',
92	    	cancel: 'touchend',
93	    	end: 'touchend'
94	    };
95
96
97	// Constructors
98	
99	function Timer(fn){
100		var callback = fn,
101		    active = false,
102		    running = false;
103		
104		function trigger(time) {
105			if (active){
106				callback();
107				requestFrame(trigger);
108				running = true;
109				active = false;
110			}
111			else {
112				running = false;
113			}
114		}
115		
116		this.kick = function(fn) {
117			active = true;
118			if (!running) { trigger(); }
119		};
120		
121		this.end = function(fn) {
122			var cb = callback;
123			
124			if (!fn) { return; }
125			
126			// If the timer is not running, simply call the end callback.
127			if (!running) {
128				fn();
129			}
130			// If the timer is running, and has been kicked lately, then
131			// queue up the current callback and the end callback, otherwise
132			// just the end callback.
133			else {
134				callback = active ?
135					function(){ cb(); fn(); } : 
136					fn ;
137				
138				active = true;
139			}
140		};
141	}
142
143
144	// Functions
145	
146	function returnTrue() {
147		return true;
148	}
149	
150	function returnFalse() {
151		return false;
152	}
153	
154	function preventDefault(e) {
155		e.preventDefault();
156	}
157	
158	function preventIgnoreTags(e) {
159		// Don't prevent interaction with form elements.
160		if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; }
161		
162		e.preventDefault();
163	}
164
165	function isLeftButton(e) {
166		// Ignore mousedowns on any button other than the left (or primary)
167		// mouse button, or when a modifier key is pressed.
168		return (e.which === 1 && !e.ctrlKey && !e.altKey);
169	}
170
171	function identifiedTouch(touchList, id) {
172		var i, l;
173
174		if (touchList.identifiedTouch) {
175			return touchList.identifiedTouch(id);
176		}
177		
178		// touchList.identifiedTouch() does not exist in
179		// webkit yet… we must do the search ourselves...
180		
181		i = -1;
182		l = touchList.length;
183		
184		while (++i < l) {
185			if (touchList[i].identifier === id) {
186				return touchList[i];
187			}
188		}
189	}
190
191	function changedTouch(e, event) {
192		var touch = identifiedTouch(e.changedTouches, event.identifier);
193
194		// This isn't the touch you're looking for.
195		if (!touch) { return; }
196
197		// Chrome Android (at least) includes touches that have not
198		// changed in e.changedTouches. That's a bit annoying. Check
199		// that this touch has changed.
200		if (touch.pageX === event.pageX && touch.pageY === event.pageY) { return; }
201
202		return touch;
203	}
204
205
206	// Handlers that decide when the first movestart is triggered
207	
208	function mousedown(e){
209		var data;
210
211		if (!isLeftButton(e)) { return; }
212
213		data = {
214			target: e.target,
215			startX: e.pageX,
216			startY: e.pageY,
217			timeStamp: e.timeStamp
218		};
219
220		add(document, mouseevents.move, mousemove, data);
221		add(document, mouseevents.cancel, mouseend, data);
222	}
223
224	function mousemove(e){
225		var data = e.data;
226
227		checkThreshold(e, data, e, removeMouse);
228	}
229
230	function mouseend(e) {
231		removeMouse();
232	}
233
234	function removeMouse() {
235		remove(document, mouseevents.move, mousemove);
236		remove(document, mouseevents.cancel, mouseend);
237	}
238
239	function touchstart(e) {
240		var touch, template;
241
242		// Don't get in the way of interaction with form elements.
243		if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; }
244
245		touch = e.changedTouches[0];
246		
247		// iOS live updates the touch objects whereas Android gives us copies.
248		// That means we can't trust the touchstart object to stay the same,
249		// so we must copy the data. This object acts as a template for
250		// movestart, move and moveend event objects.
251		template = {
252			target: touch.target,
253			startX: touch.pageX,
254			startY: touch.pageY,
255			timeStamp: e.timeStamp,
256			identifier: touch.identifier
257		};
258
259		// Use the touch identifier as a namespace, so that we can later
260		// remove handlers pertaining only to this touch.
261		add(document, touchevents.move + '.' + touch.identifier, touchmove, template);
262		add(document, touchevents.cancel + '.' + touch.identifier, touchend, template);
263	}
264
265	function touchmove(e){
266		var data = e.data,
267		    touch = changedTouch(e, data);
268
269		if (!touch) { return; }
270
271		checkThreshold(e, data, touch, removeTouch);
272	}
273
274	function touchend(e) {
275		var template = e.data,
276		    touch = identifiedTouch(e.changedTouches, template.identifier);
277
278		if (!touch) { return; }
279
280		removeTouch(template.identifier);
281	}
282
283	function removeTouch(identifier) {
284		remove(document, '.' + identifier, touchmove);
285		remove(document, '.' + identifier, touchend);
286	}
287
288
289	// Logic for deciding when to trigger a movestart.
290
291	function checkThreshold(e, template, touch, fn) {
292		var distX = touch.pageX - template.startX,
293		    distY = touch.pageY - template.startY;
294
295		// Do nothing if the threshold has not been crossed.
296		if ((distX * distX) + (distY * distY) < (threshold * threshold)) { return; }
297
298		triggerStart(e, template, touch, distX, distY, fn);
299	}
300
301	function handled() {
302		// this._handled should return false once, and after return true.
303		this._handled = returnTrue;
304		return false;
305	}
306
307	function flagAsHandled(e) {
308		e._handled();
309	}
310
311	function triggerStart(e, template, touch, distX, distY, fn) {
312		var node = template.target,
313		    touches, time;
314
315		touches = e.targetTouches;
316		time = e.timeStamp - template.timeStamp;
317
318		// Create a movestart object with some special properties that
319		// are passed only to the movestart handlers.
320		template.type = 'movestart';
321		template.distX = distX;
322		template.distY = distY;
323		template.deltaX = distX;
324		template.deltaY = distY;
325		template.pageX = touch.pageX;
326		template.pageY = touch.pageY;
327		template.velocityX = distX / time;
328		template.velocityY = distY / time;
329		template.targetTouches = touches;
330		template.finger = touches ?
331			touches.length :
332			1 ;
333
334		// The _handled method is fired to tell the default movestart
335		// handler that one of the move events is bound.
336		template._handled = handled;
337			
338		// Pass the touchmove event so it can be prevented if or when
339		// movestart is handled.
340		template._preventTouchmoveDefault = function() {
341			e.preventDefault();
342		};
343
344		// Trigger the movestart event.
345		trigger(template.target, template);
346
347		// Unbind handlers that tracked the touch or mouse up till now.
348		fn(template.identifier);
349	}
350
351
352	// Handlers that control what happens following a movestart
353
354	function activeMousemove(e) {
355		var timer = e.data.timer;
356
357		e.data.touch = e;
358		e.data.timeStamp = e.timeStamp;
359		timer.kick();
360	}
361
362	function activeMouseend(e) {
363		var event = e.data.event,
364		    timer = e.data.timer;
365		
366		removeActiveMouse();
367
368		endEvent(event, timer, function() {
369			// Unbind the click suppressor, waiting until after mouseup
370			// has been handled.
371			setTimeout(function(){
372				remove(event.target, 'click', returnFalse);
373			}, 0);
374		});
375	}
376
377	function removeActiveMouse(event) {
378		remove(document, mouseevents.move, activeMousemove);
379		remove(document, mouseevents.end, activeMouseend);
380	}
381
382	function activeTouchmove(e) {
383		var event = e.data.event,
384		    timer = e.data.timer,
385		    touch = changedTouch(e, event);
386
387		if (!touch) { return; }
388
389		// Stop the interface from gesturing
390		e.preventDefault();
391
392		event.targetTouches = e.targetTouches;
393		e.data.touch = touch;
394		e.data.timeStamp = e.timeStamp;
395		timer.kick();
396	}
397
398	function activeTouchend(e) {
399		var event = e.data.event,
400		    timer = e.data.timer,
401		    touch = identifiedTouch(e.changedTouches, event.identifier);
402
403		// This isn't the touch you're looking for.
404		if (!touch) { return; }
405
406		removeActiveTouch(event);
407		endEvent(event, timer);
408	}
409
410	function removeActiveTouch(event) {
411		remove(document, '.' + event.identifier, activeTouchmove);
412		remove(document, '.' + event.identifier, activeTouchend);
413	}
414
415
416	// Logic for triggering move and moveend events
417
418	function updateEvent(event, touch, timeStamp, timer) {
419		var time = timeStamp - event.timeStamp;
420
421		event.type = 'move';
422		event.distX =  touch.pageX - event.startX;
423		event.distY =  touch.pageY - event.startY;
424		event.deltaX = touch.pageX - event.pageX;
425		event.deltaY = touch.pageY - event.pageY;
426		
427		// Average the velocity of the last few events using a decay
428		// curve to even out spurious jumps in values.
429		event.velocityX = 0.3 * event.velocityX + 0.7 * event.deltaX / time;
430		event.velocityY = 0.3 * event.velocityY + 0.7 * event.deltaY / time;
431		event.pageX =  touch.pageX;
432		event.pageY =  touch.pageY;
433	}
434
435	function endEvent(event, timer, fn) {
436		timer.end(function(){
437			event.type = 'moveend';
438
439			trigger(event.target, event);
440			
441			return fn && fn();
442		});
443	}
444
445
446	// jQuery special event definition
447
448	function setup(data, namespaces, eventHandle) {
449		// Stop the node from being dragged
450		//add(this, 'dragstart.move drag.move', preventDefault);
451		
452		// Prevent text selection and touch interface scrolling
453		//add(this, 'mousedown.move', preventIgnoreTags);
454		
455		// Tell movestart default handler that we've handled this
456		add(this, 'movestart.move', flagAsHandled);
457
458		// Don't bind to the DOM. For speed.
459		return true;
460	}
461	
462	function teardown(namespaces) {
463		remove(this, 'dragstart drag', preventDefault);
464		remove(this, 'mousedown touchstart', preventIgnoreTags);
465		remove(this, 'movestart', flagAsHandled);
466		
467		// Don't bind to the DOM. For speed.
468		return true;
469	}
470	
471	function addMethod(handleObj) {
472		// We're not interested in preventing defaults for handlers that
473		// come from internal move or moveend bindings
474		if (handleObj.namespace === "move" || handleObj.namespace === "moveend") {
475			return;
476		}
477		
478		// Stop the node from being dragged
479		add(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid, preventDefault, undefined, handleObj.selector);
480		
481		// Prevent text selection and touch interface scrolling
482		add(this, 'mousedown.' + handleObj.guid, preventIgnoreTags, undefined, handleObj.selector);
483	}
484	
485	function removeMethod(handleObj) {
486		if (handleObj.namespace === "move" || handleObj.namespace === "moveend") {
487			return;
488		}
489		
490		remove(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid);
491		remove(this, 'mousedown.' + handleObj.guid);
492	}
493	
494	jQuery.event.special.movestart = {
495		setup: setup,
496		teardown: teardown,
497		add: addMethod,
498		remove: removeMethod,
499
500		_default: function(e) {
501			var event, data;
502			
503			// If no move events were bound to any ancestors of this
504			// target, high tail it out of here.
505			if (!e._handled()) { return; }
506
507			function update(time) {
508				updateEvent(event, data.touch, data.timeStamp);
509				trigger(e.target, event);
510			}
511
512			event = {
513				target: e.target,
514				startX: e.startX,
515				startY: e.startY,
516				pageX: e.pageX,
517				pageY: e.pageY,
518				distX: e.distX,
519				distY: e.distY,
520				deltaX: e.deltaX,
521				deltaY: e.deltaY,
522				velocityX: e.velocityX,
523				velocityY: e.velocityY,
524				timeStamp: e.timeStamp,
525				identifier: e.identifier,
526				targetTouches: e.targetTouches,
527				finger: e.finger
528			};
529
530			data = {
531				event: event,
532				timer: new Timer(update),
533				touch: undefined,
534				timeStamp: undefined
535			};
536			
537			if (e.identifier === undefined) {
538				// We're dealing with a mouse
539				// Stop clicks from propagating during a move
540				add(e.target, 'click', returnFalse);
541				add(document, mouseevents.move, activeMousemove, data);
542				add(document, mouseevents.end, activeMouseend, data);
543			}
544			else {
545				// We're dealing with a touch. Stop touchmove doing
546				// anything defaulty.
547				e._preventTouchmoveDefault();
548				add(document, touchevents.move + '.' + e.identifier, activeTouchmove, data);
549				add(document, touchevents.end + '.' + e.identifier, activeTouchend, data);
550			}
551		}
552	};
553
554	jQuery.event.special.move = {
555		setup: function() {
556			// Bind a noop to movestart. Why? It's the movestart
557			// setup that decides whether other move events are fired.
558			add(this, 'movestart.move', jQuery.noop);
559		},
560		
561		teardown: function() {
562			remove(this, 'movestart.move', jQuery.noop);
563		}
564	};
565	
566	jQuery.event.special.moveend = {
567		setup: function() {
568			// Bind a noop to movestart. Why? It's the movestart
569			// setup that decides whether other move events are fired.
570			add(this, 'movestart.moveend', jQuery.noop);
571		},
572		
573		teardown: function() {
574			remove(this, 'movestart.moveend', jQuery.noop);
575		}
576	};
577
578	add(document, 'mousedown.move', mousedown);
579	add(document, 'touchstart.move', touchstart);
580
581	// Make jQuery copy touch event properties over to the jQuery event
582	// object, if they are not already listed. But only do the ones we
583	// really need. IE7/8 do not have Array#indexOf(), but nor do they
584	// have touch events, so let's assume we can ignore them.
585	if (typeof Array.prototype.indexOf === 'function') {
586		(function(jQuery, undefined){
587			var props = ["changedTouches", "targetTouches"],
588			    l = props.length;
589			
590			while (l--) {
591				if (jQuery.event.props.indexOf(props[l]) === -1) {
592					jQuery.event.props.push(props[l]);
593				}
594			}
595		})(jQuery);
596	};
597});
598
599}
600
601/*
602     FILE ARCHIVED ON 19:48:02 Dec 14, 2023 AND RETRIEVED FROM THE
603     INTERNET ARCHIVE ON 10:29:33 Aug 04, 2026.
604     JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
605
606     ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
607     SECTION 108(a)(3)).
608*/
609/*
610playback timings (ms):
611  captures_list: 0.921
612  exclusion.robots: 0.095
613  exclusion.robots.policy: 0.075
614  esindex: 0.015
615  cdx.remote: 39.485
616  LoadShardBlock: 80.767 (3)
617  PetaboxLoader3.datanode: 188.702 (5)
618  load_resource: 168.869
619  PetaboxLoader3.resolve: 41.715
620  loaddict: 114.219
621*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.