vevet 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/CustomScrollDragPlugin/index.js +3 -0
- package/lib/cjs/components/CustomScrollDragPlugin/index.js.map +1 -1
- package/lib/cjs/components/DraggerBase/index.js +29 -114
- package/lib/cjs/components/DraggerBase/index.js.map +1 -1
- package/lib/cjs/components/DraggerDirection/index.js +7 -8
- package/lib/cjs/components/DraggerDirection/index.js.map +1 -1
- package/lib/cjs/components/DraggerMove/index.js +81 -62
- package/lib/cjs/components/DraggerMove/index.js.map +1 -1
- package/lib/cjs/components/Marquee/index.js +4 -2
- package/lib/cjs/components/Marquee/index.js.map +1 -1
- package/lib/cjs/components/ScrollBar/Bar/index.js +1 -2
- package/lib/cjs/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/cjs/components/SlideProgress/index.js +32 -58
- package/lib/cjs/components/SlideProgress/index.js.map +1 -1
- package/lib/cjs/utils/scroll/index.js +0 -1
- package/lib/cjs/utils/scroll/index.js.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/components/CustomScrollDragPlugin/index.js +3 -0
- package/lib/esm/components/CustomScrollDragPlugin/index.js.map +1 -1
- package/lib/esm/components/DraggerBase/index.js +29 -105
- package/lib/esm/components/DraggerBase/index.js.map +1 -1
- package/lib/esm/components/DraggerDirection/index.js +7 -8
- package/lib/esm/components/DraggerDirection/index.js.map +1 -1
- package/lib/esm/components/DraggerMove/index.js +81 -62
- package/lib/esm/components/DraggerMove/index.js.map +1 -1
- package/lib/esm/components/Marquee/index.js +4 -2
- package/lib/esm/components/Marquee/index.js.map +1 -1
- package/lib/esm/components/ScrollBar/Bar/index.js +1 -2
- package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/esm/components/SlideProgress/index.js +33 -57
- package/lib/esm/components/SlideProgress/index.js.map +1 -1
- package/lib/esm/utils/scroll/index.js +0 -1
- package/lib/esm/utils/scroll/index.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/components/CustomScrollDragPlugin/index.d.ts.map +1 -1
- package/lib/types/components/DraggerBase/index.d.ts +5 -56
- package/lib/types/components/DraggerBase/index.d.ts.map +1 -1
- package/lib/types/components/DraggerBase/types.d.ts +5 -9
- package/lib/types/components/DraggerBase/types.d.ts.map +1 -1
- package/lib/types/components/DraggerDirection/index.d.ts +3 -3
- package/lib/types/components/DraggerDirection/index.d.ts.map +1 -1
- package/lib/types/components/DraggerMove/index.d.ts +27 -22
- package/lib/types/components/DraggerMove/index.d.ts.map +1 -1
- package/lib/types/components/DraggerMove/types.d.ts +7 -10
- package/lib/types/components/DraggerMove/types.d.ts.map +1 -1
- package/lib/types/components/Marquee/index.d.ts.map +1 -1
- package/lib/types/components/ScrollBar/Bar/index.d.ts.map +1 -1
- package/lib/types/components/SlideProgress/index.d.ts +2 -13
- package/lib/types/components/SlideProgress/index.d.ts.map +1 -1
- package/lib/types/components/SlideProgress/types.d.ts +3 -1
- package/lib/types/components/SlideProgress/types.d.ts.map +1 -1
- package/lib/types/utils/scroll/index.d.ts +0 -1
- package/lib/types/utils/scroll/index.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/CustomScrollDragPlugin/index.ts +4 -0
- package/src/components/DraggerBase/index.ts +41 -142
- package/src/components/DraggerBase/types.ts +5 -11
- package/src/components/DraggerDirection/index.ts +12 -11
- package/src/components/DraggerDirection/stories/index.tsx +1 -0
- package/src/components/DraggerMove/index.ts +100 -77
- package/src/components/DraggerMove/stories/index.stories.tsx +3 -1
- package/src/components/DraggerMove/stories/index.tsx +7 -4
- package/src/components/DraggerMove/types.ts +8 -11
- package/src/components/Marquee/index.ts +5 -2
- package/src/components/Marquee/stories/index.tsx +3 -1
- package/src/components/ScrollBar/Bar/index.ts +0 -3
- package/src/components/SlideProgress/index.ts +40 -78
- package/src/components/SlideProgress/types.ts +3 -1
- package/src/utils/scroll/index.ts +0 -1
- package/src/version.ts +1 -1
- package/lib/cjs/utils/scroll/isPageScrolling.js +0 -73
- package/lib/cjs/utils/scroll/isPageScrolling.js.map +0 -1
- package/lib/esm/utils/scroll/isPageScrolling.js +0 -69
- package/lib/esm/utils/scroll/isPageScrolling.js.map +0 -1
- package/lib/types/utils/scroll/isPageScrolling.d.ts +0 -25
- package/lib/types/utils/scroll/isPageScrolling.d.ts.map +0 -1
- package/src/utils/scroll/isPageScrolling.ts +0 -80
|
@@ -59,6 +59,7 @@ var CustomScrollDragPlugin = /** @class */ (function (_super) {
|
|
|
59
59
|
CustomScrollDragPlugin.prototype._init = function () {
|
|
60
60
|
_super.prototype._init.call(this);
|
|
61
61
|
this._toggleDragger();
|
|
62
|
+
this.component.container.style.touchAction = 'none';
|
|
62
63
|
};
|
|
63
64
|
CustomScrollDragPlugin.prototype._onPropsMutate = function () {
|
|
64
65
|
_super.prototype._onPropsMutate.call(this);
|
|
@@ -86,6 +87,8 @@ var CustomScrollDragPlugin = /** @class */ (function (_super) {
|
|
|
86
87
|
var component = this.component;
|
|
87
88
|
this._dragger = new DraggerMove_1.DraggerMove({
|
|
88
89
|
container: component.container,
|
|
90
|
+
threshold: 0,
|
|
91
|
+
preventDefault: false,
|
|
89
92
|
});
|
|
90
93
|
this._dragger.addCallback('start', function () { return _this._handleDragStart(); });
|
|
91
94
|
this._dragger.addCallback('move', function (data) { return _this._handleDragMove(data); });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/CustomScrollDragPlugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAuC;AAGvC,8CAA2D;AAK3D;;;;;;;GAOG;AACH;IAOU,0CAKT;IAZD;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/CustomScrollDragPlugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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A3ND,CAOU,eAAM,GAoNf;AA3NY,wDAAsB"}
|
|
@@ -51,10 +51,9 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
51
51
|
}
|
|
52
52
|
// Initialize default variables
|
|
53
53
|
_this._runtimeListeners = [];
|
|
54
|
-
_this._pointerID = null;
|
|
55
54
|
_this._coords = { x: 0, y: 0 };
|
|
56
55
|
_this._prevCoords = { x: 0, y: 0 };
|
|
57
|
-
_this.
|
|
56
|
+
_this._start = { x: 0, y: 0 };
|
|
58
57
|
// Set styles to prevent user-select during drag
|
|
59
58
|
_this._fixStyles = document.createElement('style');
|
|
60
59
|
_this._fixStyles.innerHTML = '* { user-select: none !important; }';
|
|
@@ -64,7 +63,7 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
64
63
|
return _this;
|
|
65
64
|
}
|
|
66
65
|
DraggerBase.prototype._getDefaultProps = function () {
|
|
67
|
-
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { container: "#".concat(this.prefix),
|
|
66
|
+
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { container: "#".concat(this.prefix), isEnabled: true, preventDefault: true });
|
|
68
67
|
};
|
|
69
68
|
Object.defineProperty(DraggerBase.prototype, "prefix", {
|
|
70
69
|
get: function () {
|
|
@@ -93,16 +92,6 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
93
92
|
enumerable: false,
|
|
94
93
|
configurable: true
|
|
95
94
|
});
|
|
96
|
-
Object.defineProperty(DraggerBase.prototype, "pointerID", {
|
|
97
|
-
/**
|
|
98
|
-
* Returns the current pointer ID.
|
|
99
|
-
*/
|
|
100
|
-
get: function () {
|
|
101
|
-
return this._pointerID;
|
|
102
|
-
},
|
|
103
|
-
enumerable: false,
|
|
104
|
-
configurable: true
|
|
105
|
-
});
|
|
106
95
|
Object.defineProperty(DraggerBase.prototype, "coords", {
|
|
107
96
|
/**
|
|
108
97
|
* Returns the current pointer coordinates.
|
|
@@ -135,22 +124,12 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
135
124
|
enumerable: false,
|
|
136
125
|
configurable: true
|
|
137
126
|
});
|
|
138
|
-
Object.defineProperty(DraggerBase.prototype, "
|
|
127
|
+
Object.defineProperty(DraggerBase.prototype, "start", {
|
|
139
128
|
/**
|
|
140
129
|
* Returns the starting pointer coordinates at the beginning of the drag.
|
|
141
130
|
*/
|
|
142
131
|
get: function () {
|
|
143
|
-
return this.
|
|
144
|
-
},
|
|
145
|
-
enumerable: false,
|
|
146
|
-
configurable: true
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(DraggerBase.prototype, "type", {
|
|
149
|
-
/**
|
|
150
|
-
* Returns the type of event ('mouse' or 'touch') being handled.
|
|
151
|
-
*/
|
|
152
|
-
get: function () {
|
|
153
|
-
return this._type;
|
|
132
|
+
return this._start;
|
|
154
133
|
},
|
|
155
134
|
enumerable: false,
|
|
156
135
|
configurable: true
|
|
@@ -164,26 +143,20 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
164
143
|
*/
|
|
165
144
|
DraggerBase.prototype._setEvents = function () {
|
|
166
145
|
var _this = this;
|
|
167
|
-
this.addEventListener(this.container, '
|
|
168
|
-
this.addEventListener(this.container, '
|
|
146
|
+
this.addEventListener(this.container, 'pointerdown', function (event) { return _this._handleStart(event); }, { passive: false });
|
|
147
|
+
this.addEventListener(this.container, 'dragstart', function (event) { return event.preventDefault(); }, { passive: false });
|
|
169
148
|
};
|
|
170
149
|
/**
|
|
171
150
|
* Adds runtime events for mouseup, touchend, and other events during dragging.
|
|
172
151
|
*/
|
|
173
152
|
DraggerBase.prototype._addRuntimeEvents = function () {
|
|
174
153
|
var _this = this;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
passive: isPassive,
|
|
154
|
+
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'pointerup', function (event) { return _this._handleEnd(event); }, {
|
|
155
|
+
passive: false,
|
|
178
156
|
}));
|
|
179
|
-
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, '
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'touchcancel', function () { return _this.cancel(); }, {
|
|
183
|
-
passive: isPassive,
|
|
184
|
-
}));
|
|
185
|
-
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'blur', function () { return _this.cancel(); }, {
|
|
186
|
-
passive: isPassive,
|
|
157
|
+
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'pointercancel', function (event) { return _this._handleEnd(event); }, { passive: false }));
|
|
158
|
+
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'blur', function () { return _this._handleEnd(null); }, {
|
|
159
|
+
passive: false,
|
|
187
160
|
}));
|
|
188
161
|
};
|
|
189
162
|
/**
|
|
@@ -193,104 +166,49 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
193
166
|
this._runtimeListeners.forEach(function (listener) { return listener(); });
|
|
194
167
|
this._runtimeListeners = [];
|
|
195
168
|
};
|
|
196
|
-
/**
|
|
197
|
-
* Normalizes event coordinates based on the event type (mouse or touch).
|
|
198
|
-
*
|
|
199
|
-
* @param event - The event from which to extract coordinates.
|
|
200
|
-
* @returns The pointer coordinates and pointer ID.
|
|
201
|
-
*/
|
|
202
|
-
DraggerBase.prototype._getEventCoords = function (event) {
|
|
203
|
-
if (event.type.includes('touch')) {
|
|
204
|
-
var evt_1 = event;
|
|
205
|
-
var touch = evt_1.targetTouches[0] || evt_1.changedTouches[0];
|
|
206
|
-
return {
|
|
207
|
-
x: touch.clientX,
|
|
208
|
-
y: touch.clientY,
|
|
209
|
-
pointerId: touch.identifier,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
var evt = event;
|
|
213
|
-
return {
|
|
214
|
-
x: evt.clientX,
|
|
215
|
-
y: evt.clientY,
|
|
216
|
-
pointerId: null,
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
169
|
/**
|
|
220
170
|
* Handles the start of a drag event.
|
|
221
|
-
*
|
|
222
|
-
* @param event - The event that initiated the drag (mouse or touch).
|
|
223
|
-
* @returns A boolean indicating whether the drag started successfully.
|
|
224
171
|
*/
|
|
225
172
|
DraggerBase.prototype._handleStart = function (event) {
|
|
173
|
+
var _a, _b;
|
|
226
174
|
if (!this.props.isEnabled || this.isDragging) {
|
|
227
|
-
return
|
|
228
|
-
}
|
|
229
|
-
if (event.type === 'touchstart') {
|
|
230
|
-
this._type = 'touch';
|
|
175
|
+
return;
|
|
231
176
|
}
|
|
232
|
-
|
|
233
|
-
|
|
177
|
+
// prevent right click
|
|
178
|
+
if (event.button === 2) {
|
|
179
|
+
return;
|
|
234
180
|
}
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
event.stopPropagation();
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
181
|
+
if (this.props.preventDefault) {
|
|
182
|
+
event.preventDefault();
|
|
242
183
|
}
|
|
243
184
|
// Update coordinates
|
|
244
|
-
var
|
|
185
|
+
var x = event.clientX, y = event.clientY;
|
|
245
186
|
this._coords = { x: x, y: y };
|
|
246
187
|
this._prevCoords = { x: x, y: y };
|
|
247
|
-
this.
|
|
248
|
-
this._pointerID = pointerId;
|
|
188
|
+
this._start = { x: x, y: y };
|
|
249
189
|
// Add runtime events for drag
|
|
250
190
|
this._addRuntimeEvents();
|
|
191
|
+
// reset selection
|
|
192
|
+
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.empty();
|
|
193
|
+
(_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.removeAllRanges();
|
|
251
194
|
// Apply styles to prevent user-select
|
|
252
195
|
(0, getApp_1.getApp)().body.append(this._fixStyles);
|
|
253
196
|
// Trigger start callback
|
|
254
197
|
this.callbacks.tbt('start', {
|
|
255
198
|
event: event,
|
|
256
|
-
start: this.
|
|
199
|
+
start: this.start,
|
|
257
200
|
coords: this.coords,
|
|
258
201
|
});
|
|
259
|
-
return true;
|
|
260
202
|
};
|
|
261
203
|
/**
|
|
262
204
|
* Handles the end of a drag event and initiates cleanup.
|
|
263
|
-
*
|
|
264
|
-
* @param event - The event that ended the drag (mouse or touch).
|
|
265
205
|
*/
|
|
266
|
-
DraggerBase.prototype.handleEnd = function (event) {
|
|
267
|
-
var _this = this;
|
|
268
|
-
if (this._handleEndTimeout) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
this._handleEndTimeout = setTimeout(function () {
|
|
272
|
-
var pointerId = _this._getEventCoords(event).pointerId;
|
|
273
|
-
if (!_this.isDragging || pointerId !== _this.pointerID) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
_this._handleEnd(event);
|
|
277
|
-
_this._handleEndTimeout = undefined;
|
|
278
|
-
}, 1);
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* Handles the cleanup process when dragging ends.
|
|
282
|
-
*
|
|
283
|
-
* @param event - The event that ended the drag.
|
|
284
|
-
*/
|
|
285
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
286
206
|
DraggerBase.prototype._handleEnd = function (event) {
|
|
287
|
-
this.cancel();
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Cancels the current drag operation and removes runtime events and styles.
|
|
291
|
-
*/
|
|
292
|
-
DraggerBase.prototype.cancel = function () {
|
|
293
207
|
this._removeRuntimeEvents();
|
|
208
|
+
// Update coordinates
|
|
209
|
+
if (event) {
|
|
210
|
+
this._coords = { x: event.clientX, y: event.clientY };
|
|
211
|
+
}
|
|
294
212
|
// remove styles fix
|
|
295
213
|
this._fixStyles.remove();
|
|
296
214
|
// launch callbacks
|
|
@@ -300,12 +218,9 @@ var DraggerBase = /** @class */ (function (_super) {
|
|
|
300
218
|
* Destroys the dragger component, removing events and cleaning up resources.
|
|
301
219
|
*/
|
|
302
220
|
DraggerBase.prototype._destroy = function () {
|
|
303
|
-
this.
|
|
221
|
+
this._handleEnd(null);
|
|
304
222
|
_super.prototype._destroy.call(this);
|
|
305
223
|
this._removeRuntimeEvents();
|
|
306
|
-
if (this._handleEndTimeout) {
|
|
307
|
-
clearTimeout(this._handleEndTimeout);
|
|
308
|
-
}
|
|
309
224
|
};
|
|
310
225
|
return DraggerBase;
|
|
311
226
|
}(Component_1.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerBase/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE,8CAA+D;AAC/D,mDAAkD;AAClD,iDAAgD;AAChD,mDAAkD;AAClD,kDAAiD;AAIjD;;;;;GAKG;AACH;IAMU,+BAA4D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerBase/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAEhE,8CAA+D;AAC/D,mDAAkD;AAClD,iDAAgD;AAChD,mDAAkD;AAClD,kDAAiD;AAIjD;;;;;GAKG;AACH;IAMU,+BAA4D;IA6FpE,qBAAY,YAA4C,EAAE,OAAc;QAAd,wBAAA,EAAA,cAAc;QAAxE,YACE,kBAAM,YAAY,EAAE,KAAK,CAAC,SAqB3B;QAnBC,4BAA4B;QAC5B,KAAI,CAAC,UAAU,GAAG,IAAA,qBAAS,EAAC,KAAI,CAAC,KAAK,CAAC,SAAS,CAAE,CAAC;QACnD,IAAI,CAAC,IAAA,qBAAS,EAAC,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAA,mBAAQ,EAAC,KAAI,CAAC,UAAU,CAAC,EAAE;YAC7D,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SACjC;QAED,+BAA+B;QAC/B,KAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,KAAI,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,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tC,yBAAyB;QACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE;YAC1B,KAAK,OAAA;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACO,gCAAU,GAApB,UAAqB,KAA0B;QAC7C,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAE5B,qBAAqB;QACrB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;SACvD;QAED,oBAAoB;QACpB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAEzB,mBAAmB;QACnB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACO,8BAAQ,GAAlB;QACE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEtB,iBAAM,QAAQ,WAAE,CAAC;QAEjB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IACH,kBAAC;AAAD,CAAC,AA5PD,CAMU,qBAAc,GAsPvB;AA5PqB,kCAAW"}
|
|
@@ -49,28 +49,27 @@ var DraggerDirection = /** @class */ (function (_super) {
|
|
|
49
49
|
* If the drag distance is greater than or equal to `minLength`, the corresponding direction callback is triggered.
|
|
50
50
|
*/
|
|
51
51
|
DraggerDirection.prototype._handleEnd = function (event) {
|
|
52
|
-
|
|
53
|
-
var
|
|
52
|
+
_super.prototype._handleEnd.call(this, event);
|
|
53
|
+
var _a = this, start = _a.start, coords = _a.coords;
|
|
54
|
+
var x = coords.x, y = coords.y;
|
|
54
55
|
var min = Math.abs(this.props.minLength);
|
|
55
56
|
// Detect swipe direction
|
|
56
57
|
// Swipe up
|
|
57
|
-
if (
|
|
58
|
+
if (start.y > y && Math.abs(y - start.y) >= min) {
|
|
58
59
|
this.callbacks.tbt('up', undefined);
|
|
59
60
|
}
|
|
60
61
|
// Swipe down
|
|
61
|
-
if (
|
|
62
|
+
if (start.y < y && Math.abs(y - start.y) >= min) {
|
|
62
63
|
this.callbacks.tbt('down', undefined);
|
|
63
64
|
}
|
|
64
65
|
// Swipe left
|
|
65
|
-
if (
|
|
66
|
+
if (start.x > x && Math.abs(x - start.x) >= min) {
|
|
66
67
|
this.callbacks.tbt('left', undefined);
|
|
67
68
|
}
|
|
68
69
|
// Swipe right
|
|
69
|
-
if (
|
|
70
|
+
if (start.x < x && Math.abs(x - start.x) >= min) {
|
|
70
71
|
this.callbacks.tbt('right', undefined);
|
|
71
72
|
}
|
|
72
|
-
// Call the parent class's `_handleEnd` method for further cleanup
|
|
73
|
-
_super.prototype._handleEnd.call(this, event);
|
|
74
73
|
};
|
|
75
74
|
return DraggerDirection;
|
|
76
75
|
}(DraggerBase_1.DraggerBase));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerDirection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerDirection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA6C;AAK7C;;;;;;;GAOG;AACH;IAOU,oCAAyD;IAPnE;;IAiDA,CAAC;IAzCW,2CAAgB,GAA1B;QACE,6BACK,iBAAM,gBAAgB,WAAE,KAC3B,SAAS,EAAE,EAAE,IACb;IACJ,CAAC;IAED;;;OAGG;IACO,qCAAU,GAApB,UAAqB,KAA0B;QAC7C,iBAAM,UAAU,YAAC,KAAK,CAAC,CAAC;QAElB,IAAA,KAAoB,IAAI,EAAtB,KAAK,WAAA,EAAE,MAAM,YAAS,CAAC;QACvB,IAAA,CAAC,GAAQ,MAAM,EAAd,EAAE,CAAC,GAAK,MAAM,EAAX,CAAY;QAExB,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE3C,yBAAyB;QAEzB,WAAW;QACX,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;YAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SACrC;QAED,aAAa;QACb,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;YAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;SACvC;QAED,aAAa;QACb,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;YAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;SACvC;QAED,cAAc;QACd,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;YAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;SACxC;IACH,CAAC;IACH,uBAAC;AAAD,CAAC,AAjDD,CAOU,yBAAW,GA0CpB;AAjDY,4CAAgB"}
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.DraggerMove = void 0;
|
|
30
30
|
var addEventListener_1 = require("../../utils/dom/addEventListener");
|
|
31
31
|
var DraggerBase_1 = require("../DraggerBase");
|
|
32
|
+
var getApp_1 = require("../../utils/internal/getApp");
|
|
32
33
|
/**
|
|
33
34
|
* A draggable component that triggers 'move' callbacks during drag operations.
|
|
34
35
|
* It extends the base `Dragger` functionality by providing movement-related data such as the step and difference in coordinates.
|
|
@@ -41,16 +42,20 @@ var DraggerMove = /** @class */ (function (_super) {
|
|
|
41
42
|
__extends(DraggerMove, _super);
|
|
42
43
|
function DraggerMove() {
|
|
43
44
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
45
|
+
/** Remember scroll values on start */
|
|
46
|
+
_this._startScroll = { top: 0, left: 0 };
|
|
47
|
+
/** If move callback is being called */
|
|
48
|
+
_this._isMoving = false;
|
|
44
49
|
/**
|
|
45
|
-
* Stores the absolute
|
|
50
|
+
* Stores the total absolute movement.
|
|
46
51
|
*/
|
|
47
|
-
_this.
|
|
52
|
+
_this._total = { x: 0, y: 0 };
|
|
48
53
|
return _this;
|
|
49
54
|
}
|
|
50
55
|
DraggerMove.prototype._getDefaultProps = function () {
|
|
51
|
-
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), {
|
|
56
|
+
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { threshold: 5 });
|
|
52
57
|
};
|
|
53
|
-
Object.defineProperty(DraggerMove.prototype, "
|
|
58
|
+
Object.defineProperty(DraggerMove.prototype, "step", {
|
|
54
59
|
/**
|
|
55
60
|
* Returns the difference between the current pointer coordinates and the previous coordinates (the step of movement).
|
|
56
61
|
*/
|
|
@@ -63,25 +68,25 @@ var DraggerMove = /** @class */ (function (_super) {
|
|
|
63
68
|
enumerable: false,
|
|
64
69
|
configurable: true
|
|
65
70
|
});
|
|
66
|
-
Object.defineProperty(DraggerMove.prototype, "
|
|
71
|
+
Object.defineProperty(DraggerMove.prototype, "diff", {
|
|
67
72
|
/**
|
|
68
73
|
* Returns the difference between the starting coordinates and the current coordinates.
|
|
69
74
|
*/
|
|
70
75
|
get: function () {
|
|
71
76
|
return {
|
|
72
|
-
x: this.coords.x - this.
|
|
73
|
-
y: this.coords.y - this.
|
|
77
|
+
x: this.coords.x - this.start.x,
|
|
78
|
+
y: this.coords.y - this.start.y,
|
|
74
79
|
};
|
|
75
80
|
},
|
|
76
81
|
enumerable: false,
|
|
77
82
|
configurable: true
|
|
78
83
|
});
|
|
79
|
-
Object.defineProperty(DraggerMove.prototype, "
|
|
84
|
+
Object.defineProperty(DraggerMove.prototype, "total", {
|
|
80
85
|
/**
|
|
81
|
-
* Returns the absolute
|
|
86
|
+
* Returns the total absolute movement.
|
|
82
87
|
*/
|
|
83
88
|
get: function () {
|
|
84
|
-
return this.
|
|
89
|
+
return this._total;
|
|
85
90
|
},
|
|
86
91
|
enumerable: false,
|
|
87
92
|
configurable: true
|
|
@@ -93,87 +98,101 @@ var DraggerMove = /** @class */ (function (_super) {
|
|
|
93
98
|
DraggerMove.prototype._addRuntimeEvents = function () {
|
|
94
99
|
var _this = this;
|
|
95
100
|
_super.prototype._addRuntimeEvents.call(this);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, {
|
|
109
|
-
passive: isPassive,
|
|
110
|
-
}));
|
|
101
|
+
this._runtimeListeners.push((0, addEventListener_1.addEventListener)(window, 'pointermove', function (event) { return _this._handleMove(event); }, { passive: false }));
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Handles the start of a drag event.
|
|
105
|
+
*/
|
|
106
|
+
DraggerMove.prototype._handleStart = function (event) {
|
|
107
|
+
_super.prototype._handleStart.call(this, event);
|
|
108
|
+
// Remember scroll values on start
|
|
109
|
+
this._startScroll = {
|
|
110
|
+
top: window.scrollY,
|
|
111
|
+
left: window.scrollX,
|
|
112
|
+
};
|
|
111
113
|
};
|
|
112
114
|
/**
|
|
113
115
|
* Handles the movement during dragging, updating the current coordinates and calculating the step and total movement.
|
|
114
|
-
* Disables pointer events if necessary based on the `disablePointerEventsAt` threshold.
|
|
115
116
|
*
|
|
116
117
|
* @param event - The event representing the movement (either `MouseEvent` or `TouchEvent`).
|
|
117
118
|
*/
|
|
118
119
|
DraggerMove.prototype._handleMove = function (event) {
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
var x = event.clientX, y = event.clientY;
|
|
121
|
+
var threshold = this.props.threshold;
|
|
122
|
+
// get scroll values
|
|
123
|
+
var currentScroll = {
|
|
124
|
+
top: window.scrollY,
|
|
125
|
+
left: window.scrollX,
|
|
126
|
+
};
|
|
127
|
+
var startScroll = this._startScroll;
|
|
123
128
|
// Update previous and current coordinates
|
|
124
129
|
this.prevCoords = { x: this.coords.x, y: this.coords.y };
|
|
125
130
|
this.coords = { x: x, y: y };
|
|
126
|
-
// Update
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
131
|
+
// Update total movement
|
|
132
|
+
this._total.x += Math.abs(this.step.x);
|
|
133
|
+
this._total.y += Math.abs(this.step.y);
|
|
134
|
+
// check trheshold
|
|
135
|
+
if (threshold &&
|
|
136
|
+
Math.sqrt(Math.pow(this.total.x, 2) + Math.pow(this.total.y, 2)) < Math.pow(threshold, 2)) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// check if scrolling at the moment
|
|
140
|
+
if ((0, getApp_1.getApp)().isMobile &&
|
|
141
|
+
(startScroll.top !== currentScroll.top ||
|
|
142
|
+
startScroll.left !== currentScroll.left)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// moving
|
|
146
|
+
if (!this._isMoving) {
|
|
147
|
+
this._isMoving = true;
|
|
148
|
+
this._start = { x: x, y: y };
|
|
149
|
+
this._prevCoords = { x: x, y: y };
|
|
150
|
+
}
|
|
151
|
+
// prevent defaults
|
|
152
|
+
if (this.props.preventDefault) {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
}
|
|
129
155
|
// Optionally disable pointer events during movement
|
|
130
156
|
this._togglePointerEvents(false);
|
|
131
157
|
// Trigger 'move' callback with relevant data
|
|
132
158
|
this.callbacks.tbt('move', {
|
|
133
159
|
event: event,
|
|
134
|
-
start: this.
|
|
160
|
+
start: this.start,
|
|
135
161
|
coords: this.coords,
|
|
136
|
-
step: this.
|
|
137
|
-
diff: this.
|
|
138
|
-
|
|
162
|
+
step: this.step,
|
|
163
|
+
diff: this.diff,
|
|
164
|
+
total: this.total,
|
|
139
165
|
});
|
|
140
|
-
return true;
|
|
141
166
|
};
|
|
142
167
|
/**
|
|
143
|
-
* Handles the end of
|
|
144
|
-
* Re-enables pointer events if they were disabled during movement.
|
|
145
|
-
*
|
|
146
|
-
* @param event - The event representing the end of the drag (either `MouseEvent` or `TouchEvent`).
|
|
168
|
+
* Handles the end of a drag event and initiates cleanup.
|
|
147
169
|
*/
|
|
148
|
-
DraggerMove.prototype._handleEnd = function (
|
|
149
|
-
_super.prototype._handleEnd.call(this,
|
|
150
|
-
// Reset
|
|
151
|
-
this.
|
|
170
|
+
DraggerMove.prototype._handleEnd = function () {
|
|
171
|
+
_super.prototype._handleEnd.call(this, null);
|
|
172
|
+
// Reset
|
|
173
|
+
this._total = { x: 0, y: 0 };
|
|
174
|
+
this._isMoving = false;
|
|
152
175
|
// Re-enable pointer events
|
|
153
176
|
this._togglePointerEvents(true);
|
|
154
177
|
};
|
|
178
|
+
/** Cancel dragging */
|
|
179
|
+
DraggerMove.prototype.cancel = function () {
|
|
180
|
+
this._handleEnd();
|
|
181
|
+
};
|
|
155
182
|
/**
|
|
156
|
-
* Toggles pointer events on or off
|
|
183
|
+
* Toggles pointer events on or off.
|
|
157
184
|
*
|
|
158
|
-
* @param
|
|
185
|
+
* @param isEnabled - If true, pointer events will be re-enabled.
|
|
159
186
|
*/
|
|
160
|
-
DraggerMove.prototype._togglePointerEvents = function (
|
|
161
|
-
if (typeof this.props.disablePointerEventsAt !== 'number') {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
187
|
+
DraggerMove.prototype._togglePointerEvents = function (isEnabled) {
|
|
164
188
|
if (!(this.container instanceof HTMLElement)) {
|
|
165
189
|
return;
|
|
166
190
|
}
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Destroys the dragger, cleaning up all associated events and resources.
|
|
174
|
-
*/
|
|
175
|
-
DraggerMove.prototype._destroy = function () {
|
|
176
|
-
_super.prototype._destroy.call(this);
|
|
191
|
+
var total = this.total;
|
|
192
|
+
var threshold = this.props.threshold;
|
|
193
|
+
var isEnoughToBlockListeners = total.x > threshold || total.y > threshold;
|
|
194
|
+
var isDisabled = isEnabled ? false : isEnoughToBlockListeners;
|
|
195
|
+
this.container.style.pointerEvents = isDisabled ? 'none' : '';
|
|
177
196
|
};
|
|
178
197
|
return DraggerMove;
|
|
179
198
|
}(DraggerBase_1.DraggerBase));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerMove/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAChE,8CAA2D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/DraggerMove/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAgE;AAChE,8CAA2D;AAE3D,kDAAiD;AAIjD;;;;;;;GAOG;AACH;IAMU,+BAAyD;IANnE;QAAA,qEA6LC;QA/KC,sCAAsC;QAC5B,kBAAY,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAE7C,uCAAuC;QAC7B,eAAS,GAAG,KAAK,CAAC;QAsB5B;;WAEG;QACO,YAAM,GAA0B,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,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,SAAS,YAAY,WAAW,CAAC,EAAE;YAC5C,OAAO;SACR;QAEO,IAAA,KAAK,GAAK,IAAI,MAAT,CAAU;QACf,IAAA,SAAS,GAAK,IAAI,CAAC,KAAK,UAAf,CAAgB;QAEjC,IAAM,wBAAwB,GAAG,KAAK,CAAC,CAAC,GAAG,SAAS,IAAI,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC;QAE5E,IAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,wBAAwB,CAAC;QAEhE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,CAAC;IACH,kBAAC;AAAD,CAAC,AA7LD,CAMU,yBAAW,GAuLpB;AA7LY,kCAAW"}
|
|
@@ -190,7 +190,7 @@ var Marquee = /** @class */ (function (_super) {
|
|
|
190
190
|
// Wrap text node if necessary
|
|
191
191
|
this._wrapTextNode();
|
|
192
192
|
// Store element references
|
|
193
|
-
this._elements = Array.from(
|
|
193
|
+
this._elements = Array.from(this._container.children);
|
|
194
194
|
// Handle container resizing
|
|
195
195
|
var onContainerResize = (0, listeners_1.onResize)({
|
|
196
196
|
onResize: function () { return _this._handleResize(); },
|
|
@@ -198,6 +198,8 @@ var Marquee = /** @class */ (function (_super) {
|
|
|
198
198
|
viewportTarget: 'width',
|
|
199
199
|
hasBothEvents: false,
|
|
200
200
|
});
|
|
201
|
+
// initial resize
|
|
202
|
+
this._handleResize();
|
|
201
203
|
// Resize on page load
|
|
202
204
|
(0, getApp_1.getApp)()
|
|
203
205
|
.onPageLoad()
|
|
@@ -289,7 +291,7 @@ var Marquee = /** @class */ (function (_super) {
|
|
|
289
291
|
});
|
|
290
292
|
}
|
|
291
293
|
// Update element references after cloning
|
|
292
|
-
this._elements = Array.from(
|
|
294
|
+
this._elements = Array.from(this._container.children);
|
|
293
295
|
this.resize();
|
|
294
296
|
}
|
|
295
297
|
// Trigger resize callbacks
|