1// node_modules/@ionic/core/dist/esm/gesture-controller-1bf57181.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 192export { 193 GESTURE_CONTROLLER 194};
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.