vevet 4.3.1 → 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.
Files changed (77) hide show
  1. package/lib/cjs/components/CustomScrollDragPlugin/index.js +3 -0
  2. package/lib/cjs/components/CustomScrollDragPlugin/index.js.map +1 -1
  3. package/lib/cjs/components/DraggerBase/index.js +29 -114
  4. package/lib/cjs/components/DraggerBase/index.js.map +1 -1
  5. package/lib/cjs/components/DraggerDirection/index.js +7 -8
  6. package/lib/cjs/components/DraggerDirection/index.js.map +1 -1
  7. package/lib/cjs/components/DraggerMove/index.js +81 -62
  8. package/lib/cjs/components/DraggerMove/index.js.map +1 -1
  9. package/lib/cjs/components/Marquee/index.js +2 -0
  10. package/lib/cjs/components/Marquee/index.js.map +1 -1
  11. package/lib/cjs/components/ScrollBar/Bar/index.js +1 -2
  12. package/lib/cjs/components/ScrollBar/Bar/index.js.map +1 -1
  13. package/lib/cjs/components/SlideProgress/index.js +32 -58
  14. package/lib/cjs/components/SlideProgress/index.js.map +1 -1
  15. package/lib/cjs/utils/scroll/index.js +0 -1
  16. package/lib/cjs/utils/scroll/index.js.map +1 -1
  17. package/lib/cjs/version.js +1 -1
  18. package/lib/esm/components/CustomScrollDragPlugin/index.js +3 -0
  19. package/lib/esm/components/CustomScrollDragPlugin/index.js.map +1 -1
  20. package/lib/esm/components/DraggerBase/index.js +29 -105
  21. package/lib/esm/components/DraggerBase/index.js.map +1 -1
  22. package/lib/esm/components/DraggerDirection/index.js +7 -8
  23. package/lib/esm/components/DraggerDirection/index.js.map +1 -1
  24. package/lib/esm/components/DraggerMove/index.js +81 -62
  25. package/lib/esm/components/DraggerMove/index.js.map +1 -1
  26. package/lib/esm/components/Marquee/index.js +2 -0
  27. package/lib/esm/components/Marquee/index.js.map +1 -1
  28. package/lib/esm/components/ScrollBar/Bar/index.js +1 -2
  29. package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
  30. package/lib/esm/components/SlideProgress/index.js +33 -57
  31. package/lib/esm/components/SlideProgress/index.js.map +1 -1
  32. package/lib/esm/utils/scroll/index.js +0 -1
  33. package/lib/esm/utils/scroll/index.js.map +1 -1
  34. package/lib/esm/version.js +1 -1
  35. package/lib/types/components/CustomScrollDragPlugin/index.d.ts.map +1 -1
  36. package/lib/types/components/DraggerBase/index.d.ts +5 -56
  37. package/lib/types/components/DraggerBase/index.d.ts.map +1 -1
  38. package/lib/types/components/DraggerBase/types.d.ts +5 -9
  39. package/lib/types/components/DraggerBase/types.d.ts.map +1 -1
  40. package/lib/types/components/DraggerDirection/index.d.ts +3 -3
  41. package/lib/types/components/DraggerDirection/index.d.ts.map +1 -1
  42. package/lib/types/components/DraggerMove/index.d.ts +27 -22
  43. package/lib/types/components/DraggerMove/index.d.ts.map +1 -1
  44. package/lib/types/components/DraggerMove/types.d.ts +7 -10
  45. package/lib/types/components/DraggerMove/types.d.ts.map +1 -1
  46. package/lib/types/components/Marquee/index.d.ts.map +1 -1
  47. package/lib/types/components/ScrollBar/Bar/index.d.ts.map +1 -1
  48. package/lib/types/components/SlideProgress/index.d.ts +2 -13
  49. package/lib/types/components/SlideProgress/index.d.ts.map +1 -1
  50. package/lib/types/components/SlideProgress/types.d.ts +3 -1
  51. package/lib/types/components/SlideProgress/types.d.ts.map +1 -1
  52. package/lib/types/utils/scroll/index.d.ts +0 -1
  53. package/lib/types/utils/scroll/index.d.ts.map +1 -1
  54. package/lib/types/version.d.ts +1 -1
  55. package/package.json +1 -1
  56. package/src/components/CustomScrollDragPlugin/index.ts +4 -0
  57. package/src/components/DraggerBase/index.ts +41 -142
  58. package/src/components/DraggerBase/types.ts +5 -11
  59. package/src/components/DraggerDirection/index.ts +12 -11
  60. package/src/components/DraggerDirection/stories/index.tsx +1 -0
  61. package/src/components/DraggerMove/index.ts +100 -77
  62. package/src/components/DraggerMove/stories/index.stories.tsx +3 -1
  63. package/src/components/DraggerMove/stories/index.tsx +7 -4
  64. package/src/components/DraggerMove/types.ts +8 -11
  65. package/src/components/Marquee/index.ts +3 -0
  66. package/src/components/ScrollBar/Bar/index.ts +0 -3
  67. package/src/components/SlideProgress/index.ts +40 -78
  68. package/src/components/SlideProgress/types.ts +3 -1
  69. package/src/utils/scroll/index.ts +0 -1
  70. package/src/version.ts +1 -1
  71. package/lib/cjs/utils/scroll/isPageScrolling.js +0 -73
  72. package/lib/cjs/utils/scroll/isPageScrolling.js.map +0 -1
  73. package/lib/esm/utils/scroll/isPageScrolling.js +0 -69
  74. package/lib/esm/utils/scroll/isPageScrolling.js.map +0 -1
  75. package/lib/types/utils/scroll/isPageScrolling.d.ts +0 -25
  76. package/lib/types/utils/scroll/isPageScrolling.d.ts.map +0 -1
  77. package/src/utils/scroll/isPageScrolling.ts +0 -80
@@ -1,6 +1,7 @@
1
1
  import { addEventListener } from '@/utils/dom/addEventListener';
2
2
  import { DraggerBase, NDraggerBase } from '../DraggerBase';
3
3
  import { NDraggerMove } from './types';
4
+ import { getApp } from '@/utils/internal/getApp';
4
5
 
5
6
  export type { NDraggerMove };
6
7
 
@@ -22,14 +23,20 @@ export class DraggerMove<
22
23
  protected _getDefaultProps() {
23
24
  return {
24
25
  ...super._getDefaultProps(),
25
- disablePointerEventsAt: false,
26
+ threshold: 5,
26
27
  };
27
28
  }
28
29
 
30
+ /** Remember scroll values on start */
31
+ protected _startScroll = { top: 0, left: 0 };
32
+
33
+ /** If move callback is being called */
34
+ protected _isMoving = false;
35
+
29
36
  /**
30
37
  * Returns the difference between the current pointer coordinates and the previous coordinates (the step of movement).
31
38
  */
32
- get stepCoords() {
39
+ get step() {
33
40
  return {
34
41
  x: this.coords.x - this.prevCoords.x,
35
42
  y: this.coords.y - this.prevCoords.y,
@@ -39,23 +46,23 @@ export class DraggerMove<
39
46
  /**
40
47
  * Returns the difference between the starting coordinates and the current coordinates.
41
48
  */
42
- get diffCoords() {
49
+ get diff() {
43
50
  return {
44
- x: this.coords.x - this.startCoords.x,
45
- y: this.coords.y - this.startCoords.y,
51
+ x: this.coords.x - this.start.x,
52
+ y: this.coords.y - this.start.y,
46
53
  };
47
54
  }
48
55
 
49
56
  /**
50
- * Stores the absolute difference between the start coordinates and the current coordinates during dragging.
57
+ * Stores the total absolute movement.
51
58
  */
52
- protected _absDiff: NDraggerBase.IVector2 = { x: 0, y: 0 };
59
+ protected _total: NDraggerBase.IVector2 = { x: 0, y: 0 };
53
60
 
54
61
  /**
55
- * Returns the absolute difference in coordinates (the total movement made) during dragging.
62
+ * Returns the total absolute movement.
56
63
  */
57
- get absDiff() {
58
- return this._absDiff;
64
+ get total() {
65
+ return this._total;
59
66
  }
60
67
 
61
68
  /**
@@ -65,59 +72,83 @@ export class DraggerMove<
65
72
  protected _addRuntimeEvents() {
66
73
  super._addRuntimeEvents();
67
74
 
68
- const { isPassive } = this.props;
69
-
70
75
  this._runtimeListeners.push(
71
76
  addEventListener(
72
77
  window,
73
- 'mousemove',
74
- (event) => {
75
- if (this.type === 'mouse') {
76
- this._handleMove(event);
77
- }
78
- },
79
- {
80
- passive: isPassive,
81
- },
78
+ 'pointermove',
79
+ (event) => this._handleMove(event),
80
+ { passive: false },
82
81
  ),
83
82
  );
83
+ }
84
84
 
85
- this._runtimeListeners.push(
86
- addEventListener(
87
- window,
88
- 'touchmove',
89
- (event) => {
90
- if (this.type === 'touch') {
91
- this._handleMove(event);
92
- }
93
- },
94
- {
95
- passive: isPassive,
96
- },
97
- ),
98
- );
85
+ /**
86
+ * Handles the start of a drag event.
87
+ */
88
+ protected _handleStart(event: PointerEvent) {
89
+ super._handleStart(event);
90
+
91
+ // Remember scroll values on start
92
+ this._startScroll = {
93
+ top: window.scrollY,
94
+ left: window.scrollX,
95
+ };
99
96
  }
100
97
 
101
98
  /**
102
99
  * Handles the movement during dragging, updating the current coordinates and calculating the step and total movement.
103
- * Disables pointer events if necessary based on the `disablePointerEventsAt` threshold.
104
100
  *
105
101
  * @param event - The event representing the movement (either `MouseEvent` or `TouchEvent`).
106
102
  */
107
- protected _handleMove(event: NDraggerBase.TEvent) {
108
- const { x, y, pointerId } = this._getEventCoords(event);
109
-
110
- if (!this.isDragging || pointerId !== this.pointerID) {
111
- return false;
112
- }
103
+ protected _handleMove(event: PointerEvent) {
104
+ const { clientX: x, clientY: y } = event;
105
+ const { threshold } = this.props;
106
+
107
+ // get scroll values
108
+ const currentScroll = {
109
+ top: window.scrollY,
110
+ left: window.scrollX,
111
+ };
112
+ const startScroll = this._startScroll;
113
113
 
114
114
  // Update previous and current coordinates
115
115
  this.prevCoords = { x: this.coords.x, y: this.coords.y };
116
116
  this.coords = { x, y };
117
117
 
118
- // Update absolute difference in movement
119
- this._absDiff.x += Math.abs(this.stepCoords.x);
120
- this._absDiff.y += Math.abs(this.stepCoords.y);
118
+ // Update total movement
119
+ this._total.x += Math.abs(this.step.x);
120
+ this._total.y += Math.abs(this.step.y);
121
+
122
+ // check trheshold
123
+ if (
124
+ threshold &&
125
+ Math.sqrt(this.total.x ** 2 + this.total.y ** 2) < threshold ** 2
126
+ ) {
127
+ return;
128
+ }
129
+
130
+ // check if scrolling at the moment
131
+ if (
132
+ getApp().isMobile &&
133
+ (startScroll.top !== currentScroll.top ||
134
+ startScroll.left !== currentScroll.left)
135
+ ) {
136
+ return;
137
+ }
138
+
139
+ // moving
140
+ if (!this._isMoving) {
141
+ this._isMoving = true;
142
+
143
+ this._start = { x, y };
144
+ this._prevCoords = { x, y };
145
+ }
146
+
147
+ // prevent defaults
148
+
149
+ if (this.props.preventDefault) {
150
+ event.preventDefault();
151
+ }
121
152
 
122
153
  // Optionally disable pointer events during movement
123
154
  this._togglePointerEvents(false);
@@ -125,58 +156,50 @@ export class DraggerMove<
125
156
  // Trigger 'move' callback with relevant data
126
157
  this.callbacks.tbt('move', {
127
158
  event,
128
- start: this.startCoords,
159
+ start: this.start,
129
160
  coords: this.coords,
130
- step: this.stepCoords,
131
- diff: this.diffCoords,
132
- absDiff: this.absDiff,
161
+ step: this.step,
162
+ diff: this.diff,
163
+ total: this.total,
133
164
  });
134
-
135
- return true;
136
165
  }
137
166
 
138
167
  /**
139
- * Handles the end of the drag operation, resetting the absolute difference in coordinates.
140
- * Re-enables pointer events if they were disabled during movement.
141
- *
142
- * @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.
143
169
  */
144
- protected _handleEnd(event: NDraggerBase.TEvent) {
145
- super._handleEnd(event);
170
+ protected _handleEnd() {
171
+ super._handleEnd(null);
146
172
 
147
- // Reset absolute movement difference
148
- this._absDiff = { x: 0, y: 0 };
173
+ // Reset
174
+ this._total = { x: 0, y: 0 };
175
+ this._isMoving = false;
149
176
 
150
177
  // Re-enable pointer events
151
178
  this._togglePointerEvents(true);
152
179
  }
153
180
 
181
+ /** Cancel dragging */
182
+ public cancel() {
183
+ this._handleEnd();
184
+ }
185
+
154
186
  /**
155
- * Toggles pointer events on or off based on the movement threshold defined by `disablePointerEventsAt`.
187
+ * Toggles pointer events on or off.
156
188
  *
157
- * @param isEnabledProp - If true, pointer events will be re-enabled.
189
+ * @param isEnabled - If true, pointer events will be re-enabled.
158
190
  */
159
- protected _togglePointerEvents(isEnabledProp: boolean) {
160
- if (typeof this.props.disablePointerEventsAt !== 'number') {
161
- return;
162
- }
163
-
191
+ protected _togglePointerEvents(isEnabled: boolean) {
164
192
  if (!(this.container instanceof HTMLElement)) {
165
193
  return;
166
194
  }
167
195
 
168
- const isEnabled =
169
- (Math.abs(this.diffCoords.x) < this.props.disablePointerEventsAt &&
170
- Math.abs(this.diffCoords.y) < this.props.disablePointerEventsAt) ||
171
- isEnabledProp;
196
+ const { total } = this;
197
+ const { threshold } = this.props;
172
198
 
173
- this.container.style.pointerEvents = isEnabled ? '' : 'none';
174
- }
199
+ const isEnoughToBlockListeners = total.x > threshold || total.y > threshold;
175
200
 
176
- /**
177
- * Destroys the dragger, cleaning up all associated events and resources.
178
- */
179
- protected _destroy() {
180
- super._destroy();
201
+ const isDisabled = isEnabled ? false : isEnoughToBlockListeners;
202
+
203
+ this.container.style.pointerEvents = isDisabled ? 'none' : '';
181
204
  }
182
205
  }
@@ -10,4 +10,6 @@ const meta: Meta<TComponent> = {
10
10
 
11
11
  export default meta;
12
12
 
13
- export const Default: StoryObj<TComponent> = {};
13
+ export const Default: StoryObj<TComponent> = {
14
+ args: {},
15
+ };
@@ -14,8 +14,8 @@ export const Component: FC = () => {
14
14
 
15
15
  const instance = new DraggerMove({
16
16
  container: thumb,
17
- disablePointerEventsAt: 5,
18
17
  });
18
+
19
19
  setDragger(instance);
20
20
 
21
21
  instance.addCallback('move', ({ diff }) => {
@@ -50,6 +50,7 @@ export const Component: FC = () => {
50
50
  <div
51
51
  style={{
52
52
  position: 'relative',
53
+ marginTop: 10,
53
54
  width: '300px',
54
55
  height: '300px',
55
56
  display: 'flex',
@@ -64,8 +65,8 @@ export const Component: FC = () => {
64
65
  id="drag-thumb"
65
66
  style={{
66
67
  position: 'relative',
67
- width: '150px',
68
- height: '150px',
68
+ width: '250px',
69
+ height: '250px',
69
70
  display: 'flex',
70
71
  flexDirection: 'row',
71
72
  alignItems: 'center',
@@ -74,9 +75,11 @@ export const Component: FC = () => {
74
75
  cursor: 'pointer',
75
76
  textAlign: 'center',
76
77
  color: '#fff',
78
+ opacity: 0.75,
79
+ touchAction: 'pan-y',
77
80
  }}
78
81
  >
79
- <a href="/" draggable={false} style={{ color: 'currentcolor' }}>
82
+ <a href="/" style={{ color: 'currentcolor' }}>
80
83
  Drag me
81
84
  </a>
82
85
  </div>
@@ -1,19 +1,16 @@
1
1
  import { NDraggerBase } from '../DraggerBase';
2
2
 
3
3
  export namespace NDraggerMove {
4
- export interface IStaticProps extends NDraggerBase.IStaticProps {
4
+ export interface IStaticProps extends NDraggerBase.IStaticProps {}
5
+
6
+ export interface IChangeableProps extends NDraggerBase.IChangeableProps {
5
7
  /**
6
- * Disables pointer events when the difference in coordinates exceeds the specified value (in pixels).
7
- * Set this value to a number to define the threshold after which pointer events are disabled.
8
- * Set to `false` to leave pointer events unaffected.
9
- *
10
- * @default false
8
+ * Threshold value in px. If "touch distance" will be lower than this value then dragger move events will not trigger
9
+ * @default 5
11
10
  */
12
- disablePointerEventsAt?: number | false;
11
+ threshold?: number;
13
12
  }
14
13
 
15
- export interface IChangeableProps extends NDraggerBase.IChangeableProps {}
16
-
17
14
  export interface ICallbacksTypes extends NDraggerBase.ICallbacksTypes {
18
15
  /**
19
16
  * Callback triggered during the drag movement, providing details about the current, step, and difference coordinates.
@@ -33,8 +30,8 @@ export namespace NDraggerMove {
33
30
  diff: NDraggerBase.IVector2;
34
31
 
35
32
  /**
36
- * The absolute difference in coordinates between the start position and the current position, accumulating all movement.
33
+ * Total movement
37
34
  */
38
- absDiff: NDraggerBase.IVector2;
35
+ total: NDraggerBase.IVector2;
39
36
  }
40
37
  }
@@ -206,6 +206,9 @@ export class Marquee<
206
206
  hasBothEvents: false,
207
207
  });
208
208
 
209
+ // initial resize
210
+ this._handleResize();
211
+
209
212
  // Resize on page load
210
213
  getApp()
211
214
  .onPageLoad()
@@ -243,12 +243,9 @@ export class Bar {
243
243
  * @param param - The drag event data.
244
244
  */
245
245
  private _handleThumbDrag({
246
- event,
247
246
  coords,
248
247
  start,
249
248
  }: NDraggerMove.ICallbacksTypes['move']) {
250
- event.preventDefault();
251
-
252
249
  const { scrollLine } = this;
253
250
  const { container } = this.props;
254
251
 
@@ -2,11 +2,9 @@ import { Component as ComponentClass } from '@/base/Component';
2
2
  import { NSlideProgress } from './types';
3
3
  import { clamp, lerp } from '@/utils/math';
4
4
  import { normalizeWheel } from '@/utils/scroll/normalizeWheel';
5
- import { createIsPageScrolling } from '@/utils/scroll/isPageScrolling';
6
5
  import { AnimationFrame } from '../AnimationFrame';
7
6
  import { DraggerMove, NDraggerMove } from '../DraggerMove';
8
7
  import { Timeline } from '../Timeline';
9
- import { NDraggerBase } from '../DraggerBase';
10
8
 
11
9
  export type { NSlideProgress };
12
10
 
@@ -40,12 +38,12 @@ export class SlideProgress<
40
38
  hasWheel: true,
41
39
  wheelSpeed: 1,
42
40
  stickyEndDuration: 500,
43
- dragThreshold: 3,
41
+ dragThreshold: 5,
44
42
  };
45
43
  }
46
44
 
47
45
  /** Animation frame for smooth animations */
48
- protected _animationFrame: AnimationFrame;
46
+ protected _raf: AnimationFrame;
49
47
 
50
48
  /** Dragging behavior manager */
51
49
  protected _dragger: DraggerMove;
@@ -68,14 +66,11 @@ export class SlideProgress<
68
66
  }
69
67
 
70
68
  /** Timeline for smooth transitions */
71
- protected _timelineTo?: Timeline;
69
+ protected _timeline?: Timeline;
72
70
 
73
71
  /** Timeout for sticky behavior at the end */
74
72
  protected _stickyEndTimeout?: NodeJS.Timeout;
75
73
 
76
- /** Determines if dragging is allowed */
77
- protected _canDragMove = false;
78
-
79
74
  /** Direction of progress */
80
75
  protected _direction: 1 | -1 = 1;
81
76
 
@@ -85,34 +80,34 @@ export class SlideProgress<
85
80
  /** Current handler for user interactions: 'wheel' or 'drag' */
86
81
  protected _currentHandler: 'wheel' | 'drag' = 'wheel';
87
82
 
88
- /** Checks if the page is scrolling */
89
- protected _createIsPageScrolling: ReturnType<typeof createIsPageScrolling>;
90
-
91
83
  constructor(initialProps?: StaticProps & ChangeableProps, canInit = true) {
92
84
  super(initialProps, false);
93
85
 
94
- const { container } = this.props;
86
+ const { container, hasDrag, dragDirection, dragThreshold } = this.props;
95
87
 
96
88
  // Create the animation frame
97
- this._animationFrame = new AnimationFrame();
98
- this._animationFrame.addCallback('frame', () =>
99
- this._handleAnimationFrame(),
100
- );
89
+ this._raf = new AnimationFrame();
90
+ this._raf.addCallback('frame', () => this._handleAnimationFrame());
91
+
92
+ // Create dragger
93
+ this._dragger = new DraggerMove({
94
+ container,
95
+ isEnabled: hasDrag,
96
+ threshold: dragThreshold,
97
+ });
101
98
 
102
- // Create the dragger
103
- this._dragger = new DraggerMove({ container });
104
99
  this._dragger.addCallback('move', (event) => this._handleDrag(event));
105
100
  this._dragger.addCallback('start', ({ event }) => event.stopPropagation());
106
101
  this._dragger.addCallback('end', () => this._handleDragEnd());
107
102
 
103
+ // Touch Action
104
+ container.style.touchAction = dragDirection === 'x' ? 'pan-y' : 'pan-x';
105
+
108
106
  // Add wheel event listener
109
107
  this.addEventListener(container, 'wheel', (event) =>
110
108
  this._handleWheel(event),
111
109
  );
112
110
 
113
- // Create page scrolling check
114
- this._createIsPageScrolling = createIsPageScrolling();
115
-
116
111
  // Initialize the class
117
112
  if (canInit) {
118
113
  this.init();
@@ -125,7 +120,11 @@ export class SlideProgress<
125
120
  protected _onPropsMutate() {
126
121
  super._onPropsMutate();
127
122
 
128
- this._dragger.changeProps({ isEnabled: this.props.hasDrag });
123
+ const { container, hasDrag, dragThreshold, dragDirection } = this.props;
124
+
125
+ this._dragger.changeProps({ isEnabled: hasDrag, threshold: dragThreshold });
126
+
127
+ container.style.touchAction = dragDirection === 'x' ? 'pan-y' : 'pan-x';
129
128
  }
130
129
 
131
130
  /**
@@ -133,7 +132,7 @@ export class SlideProgress<
133
132
  * @param event - The wheel event.
134
133
  */
135
134
  protected _handleWheel(event: WheelEvent) {
136
- if (this._timelineTo || !this.props.hasWheel) {
135
+ if (this._timeline || !this.props.hasWheel) {
137
136
  return;
138
137
  }
139
138
 
@@ -159,7 +158,8 @@ export class SlideProgress<
159
158
  this._direction = this._wheelIntensity > 0 ? 1 : -1;
160
159
  progress.target = clamp(progress.target + y, [min, max]);
161
160
 
162
- this._animationFrame.play();
161
+ // play animation
162
+ this._raf.play();
163
163
 
164
164
  // Set timeout for sticky behavior
165
165
  this._stickyEndTimeout = setTimeout(() => {
@@ -171,55 +171,18 @@ export class SlideProgress<
171
171
  this.callbacks.tbt('wheel', wheel);
172
172
  }
173
173
 
174
- /**
175
- * Checks if dragging is allowed.
176
- * @param absDiff - Absolute difference in dragging distance.
177
- */
178
- protected _checkCanDragMove(absDiff: NDraggerBase.IVector2) {
179
- const { dragDirection, dragThreshold } = this.props;
180
-
181
- if (this._canDragMove) {
182
- return true;
183
- }
184
-
185
- if (absDiff.x < dragThreshold && absDiff.y < dragThreshold) {
186
- return false;
187
- }
188
-
189
- if (dragDirection === 'x' && absDiff.x > absDiff.y) {
190
- this._canDragMove = true;
191
- }
192
-
193
- if (dragDirection === 'y' && absDiff.y > absDiff.x) {
194
- this._canDragMove = true;
195
- }
196
-
197
- return false;
198
- }
199
-
200
174
  /**
201
175
  * Handles the drag movement for adjusting progress.
202
176
  * @param data - The drag event data.
203
177
  */
204
178
  protected _handleDrag(data: NDraggerMove.IMoveParameter) {
205
- const isPageScrolling = this._createIsPageScrolling.get();
206
-
207
- if (this._timelineTo || !this.props.hasDrag || isPageScrolling) {
208
- return;
209
- }
210
-
211
- if (!this._checkCanDragMove(data.absDiff)) {
179
+ if (this._timeline) {
212
180
  return;
213
181
  }
214
182
 
215
183
  const { _progressLerp: progress, props } = this;
216
184
  const { container, dragSpeed, dragDirection, min, max } = props;
217
- const { event, step, diff } = data;
218
-
219
- if (event.cancelable) {
220
- event.preventDefault();
221
- }
222
- event.stopPropagation();
185
+ const { step, diff } = data;
223
186
 
224
187
  // Update handler
225
188
  this._currentHandler = 'drag';
@@ -235,7 +198,7 @@ export class SlideProgress<
235
198
  const dragDiff = dragDirection === 'y' ? diff.y : diff.x;
236
199
  this._direction = dragDiff < 0 ? 1 : -1;
237
200
 
238
- this._animationFrame.play();
201
+ this._raf.play();
239
202
 
240
203
  // Callbacks
241
204
  this.callbacks.tbt('dragMove', data);
@@ -245,9 +208,10 @@ export class SlideProgress<
245
208
  * Handles the end of a drag event and triggers sticky behavior.
246
209
  */
247
210
  private _handleDragEnd() {
248
- this._canDragMove = false;
249
-
250
211
  this._goStickyEnd();
212
+
213
+ // Callbacks
214
+ this.callbacks.tbt('dragEnd', undefined);
251
215
  }
252
216
 
253
217
  /**
@@ -285,11 +249,11 @@ export class SlideProgress<
285
249
  protected _handleAnimationFrame() {
286
250
  const { _progressLerp: progress } = this;
287
251
  const { ease, friction, step } = this.props;
288
- const { fpsMultiplier } = this._animationFrame;
252
+ const { fpsMultiplier } = this._raf;
289
253
 
290
254
  const nearestSteppedProgress = this._getNearestStep(progress.target);
291
255
 
292
- if (!this._timelineTo) {
256
+ if (!this._timeline) {
293
257
  progress.target = lerp(
294
258
  progress.target,
295
259
  nearestSteppedProgress,
@@ -303,7 +267,7 @@ export class SlideProgress<
303
267
  progress.current === progress.target &&
304
268
  progress.current % step === 0
305
269
  ) {
306
- this._animationFrame.pause();
270
+ this._raf.pause();
307
271
  }
308
272
  }
309
273
 
@@ -370,7 +334,7 @@ export class SlideProgress<
370
334
  onProgress,
371
335
  onEnd,
372
336
  }: NSlideProgress.IToProps) {
373
- this._timelineTo?.destroy();
337
+ this._timeline?.destroy();
374
338
 
375
339
  const startValue = this._progressLerp.current;
376
340
  const diff = Math.abs(startValue - endValue);
@@ -384,7 +348,7 @@ export class SlideProgress<
384
348
  );
385
349
 
386
350
  const timeline = new Timeline({ duration });
387
- this._timelineTo = timeline;
351
+ this._timeline = timeline;
388
352
 
389
353
  timeline.addCallback('progress', (data) => {
390
354
  this._progressLerp.target = lerp(startValue, endValue, data.e, 0);
@@ -394,15 +358,15 @@ export class SlideProgress<
394
358
  });
395
359
 
396
360
  timeline.addCallback('end', () => {
397
- this._timelineTo?.destroy();
398
- this._timelineTo = undefined;
361
+ this._timeline?.destroy();
362
+ this._timeline = undefined;
399
363
 
400
364
  onEnd?.();
401
365
  });
402
366
 
403
367
  timeline.play();
404
368
 
405
- this._animationFrame.play();
369
+ this._raf.play();
406
370
  }
407
371
 
408
372
  /**
@@ -411,12 +375,10 @@ export class SlideProgress<
411
375
  protected _destroy() {
412
376
  super._destroy();
413
377
 
414
- this._createIsPageScrolling.destroy();
415
-
416
- this._animationFrame.destroy();
378
+ this._raf.destroy();
417
379
  this._dragger.destroy();
418
380
 
419
- this._timelineTo?.destroy();
381
+ this._timeline?.destroy();
420
382
 
421
383
  if (this._stickyEndTimeout) {
422
384
  clearTimeout(this._stickyEndTimeout);
@@ -63,7 +63,7 @@ export namespace NSlideProgress {
63
63
  stickyEndDuration?: TDuration | null;
64
64
  /**
65
65
  * Minimum threshold for drag movements (in pixels).
66
- * @default 3
66
+ * @default 5
67
67
  */
68
68
  dragThreshold?: number;
69
69
  }
@@ -77,6 +77,8 @@ export namespace NSlideProgress {
77
77
  wheel: TNormalizeWheel;
78
78
  /** Fired when a drag event moves the slider */
79
79
  dragMove: NDraggerMove.IMoveParameter;
80
+ /** Fired when dragging ends */
81
+ dragEnd: undefined;
80
82
  }
81
83
 
82
84
  export interface IWithLerp {
@@ -1,5 +1,4 @@
1
1
  export * from './getScrollValues';
2
- export * from './isPageScrolling';
3
2
  export * from './normalizeWheel';
4
3
  export * from './onScroll';
5
4
  export * from './scrollTo';
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- const version = '4.3.1';
1
+ const version = '4.4.0';
2
2
  export default version;