vendor: 4,827 bytes, lines 1-191
1// node_modules/@ionic/core/components/gesture-controller.js 2var GestureController = class { 3 constructor() { 4 this.gestureId = 0; 5 this.requestedStart = /* @__PURE__ */ new Map(); 6 this.disabledGestures = /* @__PURE__ */ new Map(); 7 this.disabledScroll = /* @__PURE__ */ new Set(); 8 } 9 /** 10 * Creates a gesture delegate based on the GestureConfig passed 11 */ 12 createGesture(config) { 13 var _a; 14 return new GestureDelegate(this, this.newID(), config.name, (_a = config.priority) !== null && _a !== void 0 ? _a : 0, !!config.disableScroll); 15 } 16 /** 17 * Creates a blocker that will block any other gesture events from firing. Set in the ion-gesture component. 18 */ 19 createBlocker(opts = {}) { 20 return new BlockerDelegate(this, this.newID(), opts.disable, !!opts.disableScroll); 21 } 22 start(gestureName, id, priority) { 23 if (!this.canStart(gestureName)) { 24 this.requestedStart.delete(id); 25 return false; 26 } 27 this.requestedStart.set(id, priority); 28 return true; 29 } 30 capture(gestureName, id, priority) { 31 if (!this.start(gestureName, id, priority)) { 32 return false; 33 } 34 const requestedStart = this.requestedStart; 35 let maxPriority = -1e4; 36 requestedStart.forEach((value) => { 37 maxPriority = Math.max(maxPriority, value); 38 }); 39 if (maxPriority === priority) { 40 this.capturedId = id; 41 requestedStart.clear(); 42 const event = new CustomEvent("ionGestureCaptured", { detail: { gestureName } }); 43 document.dispatchEvent(event); 44 return true; 45 } 46 requestedStart.delete(id); 47 return false; 48 } 49 release(id) { 50 this.requestedStart.delete(id); 51 if (this.capturedId === id) { 52 this.capturedId = void 0; 53 } 54 } 55 disableGesture(gestureName, id) { 56 let set = this.disabledGestures.get(gestureName); 57 if (set === void 0) { 58 set = /* @__PURE__ */ new Set(); 59 this.disabledGestures.set(gestureName, set); 60 } 61 set.add(id); 62 } 63 enableGesture(gestureName, id) { 64 const set = this.disabledGestures.get(gestureName); 65 if (set !== void 0) { 66 set.delete(id); 67 } 68 } 69 disableScroll(id) { 70 this.disabledScroll.add(id); 71 if (this.disabledScroll.size === 1) { 72 document.body.classList.add(BACKDROP_NO_SCROLL); 73 } 74 } 75 enableScroll(id) { 76 this.disabledScroll.delete(id); 77 if (this.disabledScroll.size === 0) { 78 document.body.classList.remove(BACKDROP_NO_SCROLL); 79 } 80 } 81 canStart(gestureName) { 82 if (this.capturedId !== void 0) { 83 return false; 84 } 85 if (this.isDisabled(gestureName)) { 86 return false; 87 } 88 return true; 89 } 90 isCaptured() { 91 return this.capturedId !== void 0; 92 } 93 isScrollDisabled() { 94 return this.disabledScroll.size > 0; 95 } 96 isDisabled(gestureName) { 97 const disabled = this.disabledGestures.get(gestureName); 98 if (disabled && disabled.size > 0) { 99 return true; 100 } 101 return false; 102 } 103 newID() { 104 this.gestureId++; 105 return this.gestureId; 106 } 107}; 108var GestureDelegate = class { 109 constructor(ctrl, id, name, priority, disableScroll) { 110 this.id = id; 111 this.name = name; 112 this.disableScroll = disableScroll; 113 this.priority = priority * 1e6 + id; 114 this.ctrl = ctrl; 115 } 116 canStart() { 117 if (!this.ctrl) { 118 return false; 119 } 120 return this.ctrl.canStart(this.name); 121 } 122 start() { 123 if (!this.ctrl) { 124 return false; 125 } 126 return this.ctrl.start(this.name, this.id, this.priority); 127 } 128 capture() { 129 if (!this.ctrl) { 130 return false; 131 } 132 const captured = this.ctrl.capture(this.name, this.id, this.priority); 133 if (captured && this.disableScroll) { 134 this.ctrl.disableScroll(this.id); 135 } 136 return captured; 137 } 138 release() { 139 if (this.ctrl) { 140 this.ctrl.release(this.id); 141 if (this.disableScroll) { 142 this.ctrl.enableScroll(this.id); 143 } 144 } 145 } 146 destroy() { 147 this.release(); 148 this.ctrl = void 0; 149 } 150}; 151var BlockerDelegate = class { 152 constructor(ctrl, id, disable, disableScroll) { 153 this.id = id; 154 this.disable = disable; 155 this.disableScroll = disableScroll; 156 this.ctrl = ctrl; 157 } 158 block() { 159 if (!this.ctrl) { 160 return; 161 } 162 if (this.disable) { 163 for (const gesture of this.disable) { 164 this.ctrl.disableGesture(gesture, this.id); 165 } 166 } 167 if (this.disableScroll) { 168 this.ctrl.disableScroll(this.id); 169 } 170 } 171 unblock() { 172 if (!this.ctrl) { 173 return; 174 } 175 if (this.disable) { 176 for (const gesture of this.disable) { 177 this.ctrl.enableGesture(gesture, this.id); 178 } 179 } 180 if (this.disableScroll) { 181 this.ctrl.enableScroll(this.id); 182 } 183 } 184 destroy() { 185 this.unblock(); 186 this.ctrl = void 0; 187 } 188}; 189var BACKDROP_NO_SCROLL = "backdrop-no-scroll"; 190var GESTURE_CONTROLLER = new GestureController(); 191
vendor: 10,287 bytes, lines 192-601
192// node_modules/@ionic/core/components/index3.js 193var addEventListener = (el, eventName, callback, opts) => { 194 const listenerOpts = supportsPassive(el) ? { 195 capture: !!opts.capture, 196 passive: !!opts.passive 197 } : !!opts.capture; 198 let add; 199 let remove; 200 if (el["__zone_symbol__addEventListener"]) { 201 add = "__zone_symbol__addEventListener"; 202 remove = "__zone_symbol__removeEventListener"; 203 } else { 204 add = "addEventListener"; 205 remove = "removeEventListener"; 206 } 207 el[add](eventName, callback, listenerOpts); 208 return () => { 209 el[remove](eventName, callback, listenerOpts); 210 }; 211}; 212var supportsPassive = (node) => { 213 if (_sPassive === void 0) { 214 try { 215 const opts = Object.defineProperty({}, "passive", { 216 get: () => { 217 _sPassive = true; 218 } 219 }); 220 node.addEventListener("optsTest", () => { 221 return; 222 }, opts); 223 } catch (e) { 224 _sPassive = false; 225 } 226 } 227 return !!_sPassive; 228}; 229var _sPassive; 230var MOUSE_WAIT = 2e3; 231var createPointerEvents = (el, pointerDown, pointerMove, pointerUp, options) => { 232 let rmTouchStart; 233 let rmTouchMove; 234 let rmTouchEnd; 235 let rmTouchCancel; 236 let rmMouseStart; 237 let rmMouseMove; 238 let rmMouseUp; 239 let lastTouchEvent = 0; 240 const handleTouchStart = (ev) => { 241 lastTouchEvent = Date.now() + MOUSE_WAIT; 242 if (!pointerDown(ev)) { 243 return; 244 } 245 if (!rmTouchMove && pointerMove) { 246 rmTouchMove = addEventListener(el, "touchmove", pointerMove, options); 247 } 248 if (!rmTouchEnd) { 249 rmTouchEnd = addEventListener(ev.target, "touchend", handleTouchEnd, options); 250 } 251 if (!rmTouchCancel) { 252 rmTouchCancel = addEventListener(ev.target, "touchcancel", handleTouchEnd, options); 253 } 254 }; 255 const handleMouseDown = (ev) => { 256 if (lastTouchEvent > Date.now()) { 257 return; 258 } 259 if (!pointerDown(ev)) { 260 return; 261 } 262 if (!rmMouseMove && pointerMove) { 263 rmMouseMove = addEventListener(getDocument(el), "mousemove", pointerMove, options); 264 } 265 if (!rmMouseUp) { 266 rmMouseUp = addEventListener(getDocument(el), "mouseup", handleMouseUp, options); 267 } 268 }; 269 const handleTouchEnd = (ev) => { 270 stopTouch(); 271 if (pointerUp) { 272 pointerUp(ev); 273 } 274 }; 275 const handleMouseUp = (ev) => { 276 stopMouse(); 277 if (pointerUp) { 278 pointerUp(ev); 279 } 280 }; 281 const stopTouch = () => { 282 if (rmTouchMove) { 283 rmTouchMove(); 284 } 285 if (rmTouchEnd) { 286 rmTouchEnd(); 287 } 288 if (rmTouchCancel) { 289 rmTouchCancel(); 290 } 291 rmTouchMove = rmTouchEnd = rmTouchCancel = void 0; 292 }; 293 const stopMouse = () => { 294 if (rmMouseMove) { 295 rmMouseMove(); 296 } 297 if (rmMouseUp) { 298 rmMouseUp(); 299 } 300 rmMouseMove = rmMouseUp = void 0; 301 }; 302 const stop = () => { 303 stopTouch(); 304 stopMouse(); 305 }; 306 const enable = (isEnabled = true) => { 307 if (!isEnabled) { 308 if (rmTouchStart) { 309 rmTouchStart(); 310 } 311 if (rmMouseStart) { 312 rmMouseStart(); 313 } 314 rmTouchStart = rmMouseStart = void 0; 315 stop(); 316 } else { 317 if (!rmTouchStart) { 318 rmTouchStart = addEventListener(el, "touchstart", handleTouchStart, options); 319 } 320 if (!rmMouseStart) { 321 rmMouseStart = addEventListener(el, "mousedown", handleMouseDown, options); 322 } 323 } 324 }; 325 const destroy = () => { 326 enable(false); 327 pointerUp = pointerMove = pointerDown = void 0; 328 }; 329 return { 330 enable, 331 stop, 332 destroy 333 }; 334}; 335var getDocument = (node) => { 336 return node instanceof Document ? node : node.ownerDocument; 337}; 338var createPanRecognizer = (direction, thresh, maxAngle) => { 339 const radians = maxAngle * (Math.PI / 180); 340 const isDirX = direction === "x"; 341 const maxCosine = Math.cos(radians); 342 const threshold = thresh * thresh; 343 let startX = 0; 344 let startY = 0; 345 let dirty = false; 346 let isPan = 0; 347 return { 348 start(x, y) { 349 startX = x; 350 startY = y; 351 isPan = 0; 352 dirty = true; 353 }, 354 detect(x, y) { 355 if (!dirty) { 356 return false; 357 } 358 const deltaX = x - startX; 359 const deltaY = y - startY; 360 const distance = deltaX * deltaX + deltaY * deltaY; 361 if (distance < threshold) { 362 return false; 363 } 364 const hypotenuse = Math.sqrt(distance); 365 const cosine = (isDirX ? deltaX : deltaY) / hypotenuse; 366 if (cosine > maxCosine) { 367 isPan = 1; 368 } else if (cosine < -maxCosine) { 369 isPan = -1; 370 } else { 371 isPan = 0; 372 } 373 dirty = false; 374 return true; 375 }, 376 isGesture() { 377 return isPan !== 0; 378 }, 379 getDirection() { 380 return isPan; 381 } 382 }; 383}; 384var createGesture = (config) => { 385 let hasCapturedPan = false; 386 let hasStartedPan = false; 387 let hasFiredStart = true; 388 let isMoveQueued = false; 389 const finalConfig = Object.assign({ disableScroll: false, direction: "x", gesturePriority: 0, passive: true, maxAngle: 40, threshold: 10 }, config); 390 const canStart = finalConfig.canStart; 391 const onWillStart = finalConfig.onWillStart; 392 const onStart = finalConfig.onStart; 393 const onEnd = finalConfig.onEnd; 394 const notCaptured = finalConfig.notCaptured; 395 const onMove = finalConfig.onMove; 396 const threshold = finalConfig.threshold; 397 const passive = finalConfig.passive; 398 const blurOnStart = finalConfig.blurOnStart; 399 const detail = { 400 type: "pan", 401 startX: 0, 402 startY: 0, 403 startTime: 0, 404 currentX: 0, 405 currentY: 0, 406 velocityX: 0, 407 velocityY: 0, 408 deltaX: 0, 409 deltaY: 0, 410 currentTime: 0, 411 event: void 0, 412 data: void 0 413 }; 414 const pan = createPanRecognizer(finalConfig.direction, finalConfig.threshold, finalConfig.maxAngle); 415 const gesture = GESTURE_CONTROLLER.createGesture({ 416 name: config.gestureName, 417 priority: config.gesturePriority, 418 disableScroll: config.disableScroll 419 }); 420 const pointerDown = (ev) => { 421 const timeStamp = now(ev); 422 if (hasStartedPan || !hasFiredStart) { 423 return false; 424 } 425 updateDetail(ev, detail); 426 detail.startX = detail.currentX; 427 detail.startY = detail.currentY; 428 detail.startTime = detail.currentTime = timeStamp; 429 detail.velocityX = detail.velocityY = detail.deltaX = detail.deltaY = 0; 430 detail.event = ev; 431 if (canStart && canStart(detail) === false) { 432 return false; 433 } 434 gesture.release(); 435 if (!gesture.start()) { 436 return false; 437 } 438 hasStartedPan = true; 439 if (threshold === 0) { 440 return tryToCapturePan(); 441 } 442 pan.start(detail.startX, detail.startY); 443 return true; 444 }; 445 const pointerMove = (ev) => { 446 if (hasCapturedPan) { 447 if (!isMoveQueued && hasFiredStart) { 448 isMoveQueued = true; 449 calcGestureData(detail, ev); 450 requestAnimationFrame(fireOnMove); 451 } 452 return; 453 } 454 calcGestureData(detail, ev); 455 if (pan.detect(detail.currentX, detail.currentY)) { 456 if (!pan.isGesture() || !tryToCapturePan()) { 457 abortGesture(); 458 } 459 } 460 }; 461 const fireOnMove = () => { 462 if (!hasCapturedPan) { 463 return; 464 } 465 isMoveQueued = false; 466 if (onMove) { 467 onMove(detail); 468 } 469 }; 470 const tryToCapturePan = () => { 471 if (!gesture.capture()) { 472 return false; 473 } 474 hasCapturedPan = true; 475 hasFiredStart = false; 476 detail.startX = detail.currentX; 477 detail.startY = detail.currentY; 478 detail.startTime = detail.currentTime; 479 if (onWillStart) { 480 onWillStart(detail).then(fireOnStart); 481 } else { 482 fireOnStart(); 483 } 484 return true; 485 }; 486 const blurActiveElement = () => { 487 if (typeof document !== "undefined") { 488 const activeElement = document.activeElement; 489 if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur) { 490 activeElement.blur(); 491 } 492 } 493 }; 494 const fireOnStart = () => { 495 if (blurOnStart) { 496 blurActiveElement(); 497 } 498 if (onStart) { 499 onStart(detail); 500 } 501 hasFiredStart = true; 502 }; 503 const reset = () => { 504 hasCapturedPan = false; 505 hasStartedPan = false; 506 isMoveQueued = false; 507 hasFiredStart = true; 508 gesture.release(); 509 }; 510 const pointerUp = (ev) => { 511 const tmpHasCaptured = hasCapturedPan; 512 const tmpHasFiredStart = hasFiredStart; 513 reset(); 514 if (!tmpHasFiredStart) { 515 return; 516 } 517 calcGestureData(detail, ev); 518 if (tmpHasCaptured) { 519 if (onEnd) { 520 onEnd(detail); 521 } 522 return; 523 } 524 if (notCaptured) { 525 notCaptured(detail); 526 } 527 }; 528 const pointerEvents = createPointerEvents(finalConfig.el, pointerDown, pointerMove, pointerUp, { 529 capture: false, 530 passive 531 }); 532 const abortGesture = () => { 533 reset(); 534 pointerEvents.stop(); 535 if (notCaptured) { 536 notCaptured(detail); 537 } 538 }; 539 return { 540 enable(enable = true) { 541 if (!enable) { 542 if (hasCapturedPan) { 543 pointerUp(void 0); 544 } 545 reset(); 546 } 547 pointerEvents.enable(enable); 548 }, 549 destroy() { 550 gesture.destroy(); 551 pointerEvents.destroy(); 552 } 553 }; 554}; 555var calcGestureData = (detail, ev) => { 556 if (!ev) { 557 return; 558 } 559 const prevX = detail.currentX; 560 const prevY = detail.currentY; 561 const prevT = detail.currentTime; 562 updateDetail(ev, detail); 563 const currentX = detail.currentX; 564 const currentY = detail.currentY; 565 const timestamp = detail.currentTime = now(ev); 566 const timeDelta = timestamp - prevT; 567 if (timeDelta > 0 && timeDelta < 100) { 568 const velocityX = (currentX - prevX) / timeDelta; 569 const velocityY = (currentY - prevY) / timeDelta; 570 detail.velocityX = velocityX * 0.7 + detail.velocityX * 0.3; 571 detail.velocityY = velocityY * 0.7 + detail.velocityY * 0.3; 572 } 573 detail.deltaX = currentX - detail.startX; 574 detail.deltaY = currentY - detail.startY; 575 detail.event = ev; 576}; 577var updateDetail = (ev, detail) => { 578 let x = 0; 579 let y = 0; 580 if (ev) { 581 const changedTouches = ev.changedTouches; 582 if (changedTouches && changedTouches.length > 0) { 583 const touch = changedTouches[0]; 584 x = touch.clientX; 585 y = touch.clientY; 586 } else if (ev.pageX !== void 0) { 587 x = ev.pageX; 588 y = ev.pageY; 589 } 590 } 591 detail.currentX = x; 592 detail.currentY = y; 593}; 594var now = (ev) => { 595 return ev.timeStamp || Date.now(); 596}; 597 598export { 599 GESTURE_CONTROLLER, 600 createGesture 601};
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.