10 examples of 'ontouchstart in window' in JavaScript

Every line of 'ontouchstart in window' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
49_onTouchStart(e) {
50 let point = e.touches ? e.touches[0] : e;
51 this.startX = point.pageX;
52 this.startY = point.pageY;
53 window.clearTimeout(this.longTapTimeout);
54 //两点接触
55 if(e.touches.length > 1) {
56 let point2 = e.touches[1];
57 let xLen = Math.abs(point2.pageX - this.startX);
58 let yLen = Math.abs(point2.pageY - this.startY);
59 this.touchDistance = this._getDistance(xLen,yLen);
60 this.touchVector = {
61 x: point2.pageX - this.startX,
62 y: point2.pageY - this.startY
63 };
64 }else {
65 this.startTime = this._getTime();
66 this.longTapTimeout = setTimeout(()=>{
67 this._emitEvent('onLongPress');
68 },800);
69 if(this.previousTouchPoint) {
70 if( Math.abs(this.startX -this.previousTouchPoint.startX) < 10 &&
71 Math.abs(this.startY - this.previousTouchPoint.startY) < 10 &&
72 Math.abs(this.startTime - this.previousTouchTime) < 300) {
73 this._emitEvent('onDoubleTap');
74 }
75 }
76 this.previousTouchTime = this.startTime;
77 this.previousTouchPoint = {
78 startX : this.startX,
79 startY : this.startY
80 };
81 }
82}
170private _onTouchBegin(event:any):void {
171 var location = this.getLocation(this.rootDiv, event);
172 var identifier = -1;
173 if (event.hasOwnProperty("identifier")) {
174 identifier = event.identifier;
175 }
176 this.onTouchBegan(location.x, location.y, identifier);
177}
60onTouch(event) {
61 console.log('touch!')
62 if (new Date().valueOf() - this.touchTime > 100) {
63 this.drag.pointer = this.getPointer(event.center);
64 this.drag.pinched = false;
65 this.pinch.scale = this.scale;
66
67 // to avoid double fireing of this event because we have two hammer instances. (on canvas and on frame)
68 this.touchTime = new Date().valueOf();
69 }
70}
90onTouchStart($event: TouchEvent) {
91 if (this.disabled || this.touching || this.loading) return;
92 this.touching = true;
93 this.touchId = $event.targetTouches[0].identifier;
94 this.ogY =
95 this._pullPercent === 0 ? $event.targetTouches[0].pageY : $event.targetTouches[0].pageY - this._pullPercent;
96 this.initScrollTop = this.contentEl.scrollTop;
97 this._animating = false;
98}
117elBlackout.addEventListener("touchstart", function onTouchStart(e){
118 if (!waitingOnCloseTimeout) {
119 callback && callback(e);
120 cbBlackoutClick(e);
121 }
122});
128_onTouchStart(e: TouchEvent) {
129 if (!this._enabled) {
130 return;
131 }
132 this._dragging = true;
133 this._lastX = e.changedTouches[0].clientX;
134 this._lastY = e.changedTouches[0].clientY;
135 e.preventDefault();
136}
1871function onTouchStart( tracker, event ) {
1872 var time,
1873 i,
1874 touchCount = event.changedTouches.length,
1875 gPoints = [];
1876
1877 time = $.now();
1878
1879 for ( i = 0; i < touchCount; i++ ) {
1880 gPoints.push( {
1881 id: event.changedTouches[ i ].identifier,
1882 type: 'touch',
1883 // isPrimary not set - let the updatePointers functions determine it
1884 currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
1885 currentTime: time
1886 } );
1887 }
1888
1889 // simulate touchenter if not natively available
1890 if ( !$.MouseTracker.haveTouchEnter ) {
1891 updatePointersEnter( tracker, event, gPoints );
1892 }
1893
1894 if ( updatePointersDown( tracker, event, gPoints, 0 ) ) { // 0 means primary button press/release or touch contact
1895 $.stopEvent( event );
1896 capturePointer( tracker, 'touch' );
1897 }
1898
1899 $.cancelEvent( event );
1900}
28start() {
29 super.start();
30 document.documentElement.addEventListener(TOUCH_MOVE, this.latest);
31}
150onTouchStart(getId, touchId, pageX) {
151 // Ignore any touch events that start mid-swipe.
152 if (this.swipeState) {
153 return;
154 }
155
156 if (this.touchState[touchId]) {
157 // It turns out we can get multiple touch starts with no
158 // intervening move, end, or cancel events in Android WebViews.
159 // TODO(benkomalo): it's not entirely clear why this happens, but
160 // it seems to happen with the backspace button. It may be related
161 // to FastClick (https://github.com/ftlabs/fastclick/issues/71)
162 // though I haven't verified, and it's probably good to be robust
163 // here anyways.
164 return;
165 }
166
167 const startingNodeId = getId();
168 this.touchState[touchId] = {
169 swipeLocked: this.swipeDisabledNodeIds.includes(startingNodeId),
170 startX: pageX,
171 };
172
173 this._onFocus(startingNodeId, touchId);
174}
28function onTouchDown(event: EventTouch) {
29 tweenDown.start();
30}

Related snippets