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