vevet 3.3.2 → 3.5.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/base/Component/index.js.map +1 -1
- package/lib/cjs/components/AnimationFrame/index.js.map +1 -1
- package/lib/cjs/components/BaseTimeline/index.js.map +1 -1
- package/lib/cjs/components/Ctx2D/index.js.map +1 -1
- package/lib/cjs/components/Ctx2DPrerender/index.js.map +1 -1
- package/lib/cjs/components/CustomCursor/index.js.map +1 -1
- package/lib/cjs/components/DraggerBase/index.js.map +1 -1
- package/lib/cjs/components/DraggerDirection/index.js.map +1 -1
- package/lib/cjs/components/DraggerMove/index.js.map +1 -1
- package/lib/cjs/components/Preloader/index.js.map +1 -1
- package/lib/cjs/components/ProgressPreloader/index.js +4 -1
- package/lib/cjs/components/ProgressPreloader/index.js.map +1 -1
- package/lib/cjs/components/ScrollBar/index.js.map +1 -1
- package/lib/cjs/components/ScrollView/index.js.map +1 -1
- package/lib/cjs/components/SectionScrollProgress/index.js.map +1 -1
- package/lib/cjs/components/SlideProgress/index.js +185 -0
- package/lib/cjs/components/SlideProgress/index.js.map +1 -0
- package/lib/cjs/components/SlideProgress/types.js +3 -0
- package/lib/cjs/components/SlideProgress/types.js.map +1 -0
- package/lib/cjs/components/SmoothScroll/index.js.map +1 -1
- package/lib/cjs/components/SmoothScrollDragPlugin/index.js.map +1 -1
- package/lib/cjs/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
- package/lib/cjs/components/SplitText/index.js.map +1 -1
- package/lib/cjs/components/Timeline/index.js.map +1 -1
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/base/Component/index.js.map +1 -1
- package/lib/esm/components/AnimationFrame/index.js.map +1 -1
- package/lib/esm/components/BaseTimeline/index.js.map +1 -1
- package/lib/esm/components/Ctx2D/index.js.map +1 -1
- package/lib/esm/components/Ctx2DPrerender/index.js.map +1 -1
- package/lib/esm/components/CustomCursor/index.js.map +1 -1
- package/lib/esm/components/DraggerBase/index.js.map +1 -1
- package/lib/esm/components/DraggerDirection/index.js.map +1 -1
- package/lib/esm/components/DraggerMove/index.js.map +1 -1
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +4 -1
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/ScrollBar/index.js.map +1 -1
- package/lib/esm/components/ScrollView/index.js.map +1 -1
- package/lib/esm/components/SectionScrollProgress/index.js.map +1 -1
- package/lib/esm/components/SlideProgress/index.js +134 -0
- package/lib/esm/components/SlideProgress/index.js.map +1 -0
- package/lib/esm/components/SlideProgress/types.js +2 -0
- package/lib/esm/components/SlideProgress/types.js.map +1 -0
- package/lib/esm/components/SmoothScroll/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollDragPlugin/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/base/Component/index.d.ts.map +1 -1
- package/lib/types/components/AnimationFrame/index.d.ts +11 -11
- package/lib/types/components/AnimationFrame/index.d.ts.map +1 -1
- package/lib/types/components/BaseTimeline/index.d.ts +7 -4
- package/lib/types/components/BaseTimeline/index.d.ts.map +1 -1
- package/lib/types/components/Ctx2D/index.d.ts +6 -6
- package/lib/types/components/Ctx2D/index.d.ts.map +1 -1
- package/lib/types/components/Ctx2DPrerender/index.d.ts +1 -1
- package/lib/types/components/Ctx2DPrerender/index.d.ts.map +1 -1
- package/lib/types/components/CustomCursor/index.d.ts +20 -19
- package/lib/types/components/CustomCursor/index.d.ts.map +1 -1
- package/lib/types/components/DraggerBase/index.d.ts +11 -10
- package/lib/types/components/DraggerBase/index.d.ts.map +1 -1
- package/lib/types/components/DraggerDirection/index.d.ts.map +1 -1
- package/lib/types/components/DraggerMove/index.d.ts +1 -1
- package/lib/types/components/DraggerMove/index.d.ts.map +1 -1
- package/lib/types/components/Marquee/index.d.ts +2 -1
- package/lib/types/components/Marquee/index.d.ts.map +1 -1
- package/lib/types/components/Preloader/index.d.ts +7 -7
- package/lib/types/components/Preloader/index.d.ts.map +1 -1
- package/lib/types/components/ProgressPreloader/index.d.ts +11 -9
- package/lib/types/components/ProgressPreloader/index.d.ts.map +1 -1
- package/lib/types/components/ScrollBar/index.d.ts +5 -4
- package/lib/types/components/ScrollBar/index.d.ts.map +1 -1
- package/lib/types/components/ScrollView/index.d.ts +1 -1
- package/lib/types/components/ScrollView/index.d.ts.map +1 -1
- package/lib/types/components/SectionScrollProgress/index.d.ts.map +1 -1
- package/lib/types/components/SlideProgress/index.d.ts +54 -0
- package/lib/types/components/SlideProgress/index.d.ts.map +1 -0
- package/lib/types/components/SlideProgress/types.d.ts +67 -0
- package/lib/types/components/SlideProgress/types.d.ts.map +1 -0
- package/lib/types/components/SmoothScroll/index.d.ts +6 -4
- package/lib/types/components/SmoothScroll/index.d.ts.map +1 -1
- package/lib/types/components/SmoothScrollDragPlugin/index.d.ts +12 -10
- package/lib/types/components/SmoothScrollDragPlugin/index.d.ts.map +1 -1
- package/lib/types/components/SmoothScrollKeyboardPlugin/index.d.ts +5 -4
- package/lib/types/components/SmoothScrollKeyboardPlugin/index.d.ts.map +1 -1
- package/lib/types/components/SplitText/index.d.ts +13 -13
- package/lib/types/components/SplitText/index.d.ts.map +1 -1
- package/lib/types/components/Timeline/index.d.ts +5 -5
- package/lib/types/components/Timeline/index.d.ts.map +1 -1
- package/lib/types/components/index.d.ts +1 -0
- package/lib/types/components/index.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/Application/events/PageLoad/index.ts +1 -1
- package/src/Application/events/Viewport/index.ts +3 -3
- package/src/Application/index.ts +1 -1
- package/src/base/Callbacks/index.ts +2 -2
- package/src/base/Component/index.ts +4 -2
- package/src/base/Module/index.ts +13 -13
- package/src/base/Module/stories/index.tsx +1 -1
- package/src/base/MutableProps/index.ts +3 -3
- package/src/base/MutableProps/stories/index.tsx +1 -1
- package/src/base/Plugin/index.ts +2 -2
- package/src/components/AnimationFrame/index.ts +19 -16
- package/src/components/BaseTimeline/index.ts +10 -8
- package/src/components/BaseTimeline/stories/Nested.tsx +1 -1
- package/src/components/Ctx2D/index.ts +7 -7
- package/src/components/Ctx2DPrerender/index.ts +6 -3
- package/src/components/CustomCursor/index.ts +30 -28
- package/src/components/DraggerBase/index.ts +20 -18
- package/src/components/DraggerDirection/index.ts +6 -3
- package/src/components/DraggerMove/index.ts +9 -7
- package/src/components/Marquee/index.ts +3 -3
- package/src/components/Preloader/index.ts +12 -10
- package/src/components/ProgressPreloader/index.ts +25 -19
- package/src/components/ProgressPreloader/utils/preloadCustomElement.ts +1 -1
- package/src/components/ProgressPreloader/utils/preloadImage.ts +1 -1
- package/src/components/ProgressPreloader/utils/preloadVideo.ts +1 -1
- package/src/components/ScrollBar/Bar/index.ts +5 -5
- package/src/components/ScrollBar/index.ts +10 -8
- package/src/components/ScrollBar/stories/Default.tsx +1 -1
- package/src/components/ScrollBar/stories/WithInnerScroll.tsx +1 -1
- package/src/components/ScrollBar/stories/WithSmoothScrollComponent.tsx +1 -1
- package/src/components/ScrollBar/stories/index.stories.tsx +2 -2
- package/src/components/ScrollView/index.ts +13 -11
- package/src/components/ScrollView/stories/index.tsx +1 -1
- package/src/components/SectionScrollProgress/index.ts +6 -3
- package/src/components/SectionScrollProgress/stories/index.stories.tsx +1 -1
- package/src/components/SlideProgress/index.ts +226 -0
- package/src/components/SlideProgress/stories/index.stories.tsx +13 -0
- package/src/components/SlideProgress/stories/index.tsx +66 -0
- package/src/components/SlideProgress/types.ts +71 -0
- package/src/components/SmoothScroll/AnimatonFrame.ts +2 -2
- package/src/components/SmoothScroll/Elements.ts +3 -3
- package/src/components/SmoothScroll/index.ts +13 -11
- package/src/components/SmoothScroll/stories/Default.tsx +1 -1
- package/src/components/SmoothScroll/stories/WithHorizontal.tsx +1 -1
- package/src/components/SmoothScroll/stories/WithInnerLerp.tsx +1 -1
- package/src/components/SmoothScroll/stories/index.stories.tsx +2 -2
- package/src/components/SmoothScrollDragPlugin/index.ts +17 -14
- package/src/components/SmoothScrollDragPlugin/stories/index.tsx +1 -1
- package/src/components/SmoothScrollKeyboardPlugin/index.ts +11 -8
- package/src/components/SmoothScrollKeyboardPlugin/stories/index.tsx +1 -1
- package/src/components/SplitText/index.ts +18 -16
- package/src/components/Timeline/index.ts +9 -8
- package/src/components/Timeline/stories/Nested.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/utils/common/mergeWithoutArrays.ts +1 -1
- package/src/utils/common/pickObjectProps.ts +1 -1
- package/src/utils/common/times.ts +1 -1
- package/src/utils/image/load.ts +2 -2
- package/src/utils/image/pathsToProps.ts +1 -1
- package/src/utils/listeners/onResize.ts +3 -3
- package/src/utils/math/clampScope.ts +1 -1
- package/src/utils/math/easing.ts +1 -1
- package/src/utils/math/lerp.ts +1 -1
- package/src/utils/math/normalizeNestedScope.ts +1 -1
- package/src/utils/math/wrap.ts +1 -1
- package/src/utils/scroll/getScrollValues.ts +1 -1
- package/src/utils/scroll/onScroll.ts +7 -7
- package/src/version.ts +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
import React, { FC, useEffect, useRef } from 'react';
|
|
3
|
+
import { SlideProgress } from '..';
|
|
4
|
+
|
|
5
|
+
export const Component: FC = () => {
|
|
6
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
7
|
+
|
|
8
|
+
const colors = ['#A8E6CF', '#DCEDC1', '#FFD3B6', '#FFAAA5', '#FF8B94'];
|
|
9
|
+
const { length } = colors;
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!containerRef.current) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const instance = new SlideProgress({
|
|
17
|
+
container: containerRef.current,
|
|
18
|
+
min: 0,
|
|
19
|
+
max: length - 1,
|
|
20
|
+
step: 0.5,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const elements = Array.from(containerRef.current.children) as HTMLElement[];
|
|
24
|
+
|
|
25
|
+
instance.addCallback('render', () => {
|
|
26
|
+
elements.forEach((element, index) => {
|
|
27
|
+
const y = instance.progress * -100 + index * 100;
|
|
28
|
+
element.style.transform = `translate(0, ${y}%)`;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
instance.render();
|
|
33
|
+
|
|
34
|
+
return () => instance.destroy();
|
|
35
|
+
}, [length]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<p>Scroll the block below</p>
|
|
40
|
+
|
|
41
|
+
<div
|
|
42
|
+
ref={containerRef}
|
|
43
|
+
style={{
|
|
44
|
+
position: 'relative',
|
|
45
|
+
width: 300,
|
|
46
|
+
height: 300,
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{colors.map((color) => (
|
|
51
|
+
<div
|
|
52
|
+
key={color}
|
|
53
|
+
style={{
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
top: '0',
|
|
56
|
+
left: '0',
|
|
57
|
+
width: '100%',
|
|
58
|
+
height: '100%',
|
|
59
|
+
backgroundColor: color,
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
))}
|
|
63
|
+
</div>
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { NComponent } from '@/base/Component/types';
|
|
2
|
+
import { NTimeline } from '../Timeline';
|
|
3
|
+
|
|
4
|
+
export namespace NSlideProgress {
|
|
5
|
+
export interface IStaticProps extends NComponent.IStaticProps {
|
|
6
|
+
/** HTML Container */
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IChangeableProps extends NComponent.IChangeableProps {
|
|
11
|
+
/** Minimum progress value */
|
|
12
|
+
min: number;
|
|
13
|
+
/** Maximum progress value */
|
|
14
|
+
max: number;
|
|
15
|
+
/** Progress step */
|
|
16
|
+
step: number;
|
|
17
|
+
/**
|
|
18
|
+
* Linear interpolation ease
|
|
19
|
+
* @default 0.1
|
|
20
|
+
*/
|
|
21
|
+
ease?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Linear interpolation friction
|
|
24
|
+
* @default 0.5
|
|
25
|
+
*/
|
|
26
|
+
friction?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Use drag events
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
hasDrag?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Dragger speed
|
|
34
|
+
* @default 1
|
|
35
|
+
*/
|
|
36
|
+
dragSpeed?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Dragger direction
|
|
39
|
+
* @default 'y'
|
|
40
|
+
*/
|
|
41
|
+
dragDirection?: 'x' | 'y';
|
|
42
|
+
/**
|
|
43
|
+
* Use wheel events
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
hasWheel?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Wheel speed
|
|
49
|
+
* @default 1
|
|
50
|
+
*/
|
|
51
|
+
wheelSpeed?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ICallbacksTypes extends NComponent.ICallbacksTypes {
|
|
55
|
+
render: undefined;
|
|
56
|
+
step: undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IWithLerp {
|
|
60
|
+
current: number;
|
|
61
|
+
target: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IToProps {
|
|
65
|
+
value: number;
|
|
66
|
+
/** @default 500 */
|
|
67
|
+
duration?: number;
|
|
68
|
+
onProgress?: (props: NTimeline.ICallbacksTypes['progress']) => void;
|
|
69
|
+
onEnd?: () => void;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -32,7 +32,7 @@ export class AnimationFrame {
|
|
|
32
32
|
this._animationFrameEvent = this.props.outerAnimationFrame.addCallback(
|
|
33
33
|
'frame',
|
|
34
34
|
() => this.props.callback(),
|
|
35
|
-
{ name: 'SmoothScroll' }
|
|
35
|
+
{ name: 'SmoothScroll' },
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -43,7 +43,7 @@ export class AnimationFrame {
|
|
|
43
43
|
if (!this._innerAnimationFrame) {
|
|
44
44
|
this._innerAnimationFrame = new AnimationFrameClass({ fps: 'auto' });
|
|
45
45
|
this._innerAnimationFrame.addCallback('frame', () =>
|
|
46
|
-
this.props.callback()
|
|
46
|
+
this.props.callback(),
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -61,8 +61,8 @@ export class Elements {
|
|
|
61
61
|
this._elements = Array.from(
|
|
62
62
|
selectAll(
|
|
63
63
|
this.props.elements,
|
|
64
|
-
this.props.container
|
|
65
|
-
) as NodeListOf<NSmoothScroll.IElement
|
|
64
|
+
this.props.container,
|
|
65
|
+
) as NodeListOf<NSmoothScroll.IElement>,
|
|
66
66
|
);
|
|
67
67
|
} else {
|
|
68
68
|
this._elements = [this._wrapper as NSmoothScroll.IElement];
|
|
@@ -123,7 +123,7 @@ export class Elements {
|
|
|
123
123
|
return array.every(
|
|
124
124
|
({ smoothScrollLeft, smoothScrollTop }) =>
|
|
125
125
|
smoothScrollLeft === array[0].smoothScrollLeft &&
|
|
126
|
-
smoothScrollTop === array[0].smoothScrollTop
|
|
126
|
+
smoothScrollTop === array[0].smoothScrollTop,
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -15,8 +15,10 @@ export type { NSmoothScroll };
|
|
|
15
15
|
*/
|
|
16
16
|
export class SmoothScroll<
|
|
17
17
|
StaticProps extends NSmoothScroll.IStaticProps = NSmoothScroll.IStaticProps,
|
|
18
|
-
ChangeableProps extends
|
|
19
|
-
|
|
18
|
+
ChangeableProps extends
|
|
19
|
+
NSmoothScroll.IChangeableProps = NSmoothScroll.IChangeableProps,
|
|
20
|
+
CallbacksTypes extends
|
|
21
|
+
NSmoothScroll.ICallbacksTypes = NSmoothScroll.ICallbacksTypes,
|
|
20
22
|
>
|
|
21
23
|
extends ComponentClass<StaticProps, ChangeableProps, CallbacksTypes>
|
|
22
24
|
implements IScrollLike
|
|
@@ -48,14 +50,14 @@ export class SmoothScroll<
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/** Scroll container */
|
|
51
|
-
|
|
53
|
+
protected _container: HTMLElement;
|
|
52
54
|
|
|
53
55
|
/** Scroll container */
|
|
54
56
|
get container() {
|
|
55
57
|
return this._container;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
protected _elements: Elements;
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Scroll wrapper. If the element does not exist indide the `container`,
|
|
@@ -194,7 +196,7 @@ export class SmoothScroll<
|
|
|
194
196
|
protected _isInstant?: boolean;
|
|
195
197
|
|
|
196
198
|
/** Animation frame */
|
|
197
|
-
|
|
199
|
+
protected _animationFrame: AnimationFrame;
|
|
198
200
|
|
|
199
201
|
/** Frame index */
|
|
200
202
|
protected _frameIndex: number;
|
|
@@ -288,7 +290,7 @@ export class SmoothScroll<
|
|
|
288
290
|
|
|
289
291
|
// wheel
|
|
290
292
|
this.addEventListener(this.container, 'wheel', (event) =>
|
|
291
|
-
this.handleWheel(event)
|
|
293
|
+
this.handleWheel(event),
|
|
292
294
|
);
|
|
293
295
|
|
|
294
296
|
// prevent native scroll
|
|
@@ -299,7 +301,7 @@ export class SmoothScroll<
|
|
|
299
301
|
}
|
|
300
302
|
|
|
301
303
|
/** Set resize events */
|
|
302
|
-
|
|
304
|
+
protected _setResize() {
|
|
303
305
|
const { viewportTarget, resizeDebounce } = this.props;
|
|
304
306
|
|
|
305
307
|
// resize handler
|
|
@@ -324,7 +326,7 @@ export class SmoothScroll<
|
|
|
324
326
|
this._recalculateScrollSizes();
|
|
325
327
|
}
|
|
326
328
|
}) as any,
|
|
327
|
-
{ isProtected: true, name: this.name }
|
|
329
|
+
{ isProtected: true, name: this.name },
|
|
328
330
|
);
|
|
329
331
|
}
|
|
330
332
|
}
|
|
@@ -365,7 +367,7 @@ export class SmoothScroll<
|
|
|
365
367
|
/** Resize the scene */
|
|
366
368
|
protected _resize(
|
|
367
369
|
/** If the method was called natively on window resize */
|
|
368
|
-
isNative = false
|
|
370
|
+
isNative = false,
|
|
369
371
|
) {
|
|
370
372
|
const { container, wrapper } = this;
|
|
371
373
|
|
|
@@ -507,13 +509,13 @@ export class SmoothScroll<
|
|
|
507
509
|
element.smoothScrollLeft = this._lerp(
|
|
508
510
|
element.smoothScrollLeft,
|
|
509
511
|
this._targetLeft,
|
|
510
|
-
elementLerp
|
|
512
|
+
elementLerp,
|
|
511
513
|
);
|
|
512
514
|
|
|
513
515
|
element.smoothScrollTop = this._lerp(
|
|
514
516
|
element.smoothScrollTop,
|
|
515
517
|
this._targetTop,
|
|
516
|
-
elementLerp
|
|
518
|
+
elementLerp,
|
|
517
519
|
);
|
|
518
520
|
}
|
|
519
521
|
}
|
|
@@ -15,9 +15,9 @@ export const Default: StoryFn<typeof DefaultComponent> = (props) => (
|
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
export const WithInnerLerp: StoryFn<typeof WithInnerLerpComponent> = (
|
|
18
|
-
props
|
|
18
|
+
props,
|
|
19
19
|
) => <WithInnerLerpComponent {...props} />;
|
|
20
20
|
|
|
21
21
|
export const WithHorizontal: StoryFn<typeof WithHorizontalComponent> = (
|
|
22
|
-
props
|
|
22
|
+
props,
|
|
23
23
|
) => <WithHorizontalComponent {...props} />;
|
|
@@ -10,9 +10,12 @@ export type { NSmoothScrollDragPlugin };
|
|
|
10
10
|
* Add dragger to `SmoothScroll`
|
|
11
11
|
*/
|
|
12
12
|
export class SmoothScrollDragPlugin<
|
|
13
|
-
StaticProp extends
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
StaticProp extends
|
|
14
|
+
NSmoothScrollDragPlugin.IStaticProps = NSmoothScrollDragPlugin.IStaticProps,
|
|
15
|
+
ChangeableProp extends
|
|
16
|
+
NSmoothScrollDragPlugin.IChangeableProps = NSmoothScrollDragPlugin.IChangeableProps,
|
|
17
|
+
CallbacksTypes extends
|
|
18
|
+
NSmoothScrollDragPlugin.ICallbacksTypes = NSmoothScrollDragPlugin.ICallbacksTypes,
|
|
16
19
|
> extends Plugin<
|
|
17
20
|
StaticProp,
|
|
18
21
|
ChangeableProp,
|
|
@@ -31,10 +34,10 @@ export class SmoothScrollDragPlugin<
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
/** Dragger component */
|
|
34
|
-
|
|
37
|
+
protected _dragger?: DraggerMove;
|
|
35
38
|
|
|
36
39
|
/** Component callbacks */
|
|
37
|
-
|
|
40
|
+
protected _componentCallbacks?: NCallbacks.IAddedCallback[];
|
|
38
41
|
|
|
39
42
|
/** If is dragging at the moment */
|
|
40
43
|
get isDragging() {
|
|
@@ -44,7 +47,7 @@ export class SmoothScrollDragPlugin<
|
|
|
44
47
|
/**
|
|
45
48
|
* Current lerp of SmoothScroll
|
|
46
49
|
*/
|
|
47
|
-
|
|
50
|
+
protected _prevComponentLerp?: number;
|
|
48
51
|
|
|
49
52
|
/** Initialize the class */
|
|
50
53
|
protected _init() {
|
|
@@ -60,7 +63,7 @@ export class SmoothScrollDragPlugin<
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
/** Add or remove dragger */
|
|
63
|
-
|
|
66
|
+
protected _toggleDragger() {
|
|
64
67
|
if (this.props.isEnabled) {
|
|
65
68
|
this._addDragger();
|
|
66
69
|
} else {
|
|
@@ -69,7 +72,7 @@ export class SmoothScrollDragPlugin<
|
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
/** Add dragger */
|
|
72
|
-
|
|
75
|
+
protected _addDragger() {
|
|
73
76
|
if (this._dragger) {
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
@@ -93,12 +96,12 @@ export class SmoothScrollDragPlugin<
|
|
|
93
96
|
this._componentCallbacks.push(
|
|
94
97
|
component.addCallback('wheel', () => this._dragger?.cancel(), {
|
|
95
98
|
name: this.name,
|
|
96
|
-
})
|
|
99
|
+
}),
|
|
97
100
|
);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
/** Remove dragger */
|
|
101
|
-
|
|
104
|
+
protected _removeDragger() {
|
|
102
105
|
if (!this._dragger) {
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
@@ -111,7 +114,7 @@ export class SmoothScrollDragPlugin<
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
/** Check if dragging is available */
|
|
114
|
-
|
|
117
|
+
protected _getIsDragAvailable() {
|
|
115
118
|
const { component } = this;
|
|
116
119
|
|
|
117
120
|
if (!component.props.isEnabled) {
|
|
@@ -130,7 +133,7 @@ export class SmoothScrollDragPlugin<
|
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
/** Callback on dragging start */
|
|
133
|
-
|
|
136
|
+
protected _handleDragStart() {
|
|
134
137
|
if (!this._getIsDragAvailable()) {
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
@@ -148,7 +151,7 @@ export class SmoothScrollDragPlugin<
|
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
/** Callback on drag move */
|
|
151
|
-
|
|
154
|
+
protected _handleDragMove({
|
|
152
155
|
event,
|
|
153
156
|
coords,
|
|
154
157
|
start,
|
|
@@ -199,7 +202,7 @@ export class SmoothScrollDragPlugin<
|
|
|
199
202
|
/**
|
|
200
203
|
* Callback on dragging end
|
|
201
204
|
*/
|
|
202
|
-
|
|
205
|
+
protected _handleDragEnd() {
|
|
203
206
|
const { component } = this;
|
|
204
207
|
|
|
205
208
|
// update styles
|
|
@@ -9,9 +9,12 @@ export type { NSmoothScrollKeyboardPlugin };
|
|
|
9
9
|
* Add keyboard navigation
|
|
10
10
|
*/
|
|
11
11
|
export class SmoothScrollKeyboardPlugin<
|
|
12
|
-
StaticProps extends
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
StaticProps extends
|
|
13
|
+
NSmoothScrollKeyboardPlugin.IStaticProps = NSmoothScrollKeyboardPlugin.IStaticProps,
|
|
14
|
+
ChangeableProps extends
|
|
15
|
+
NSmoothScrollKeyboardPlugin.IChangeableProps = NSmoothScrollKeyboardPlugin.IChangeableProps,
|
|
16
|
+
CallbacksTypes extends
|
|
17
|
+
NSmoothScrollKeyboardPlugin.ICallbacksTypes = NSmoothScrollKeyboardPlugin.ICallbacksTypes,
|
|
15
18
|
> extends Plugin<
|
|
16
19
|
StaticProps,
|
|
17
20
|
ChangeableProps,
|
|
@@ -25,19 +28,19 @@ export class SmoothScrollKeyboardPlugin<
|
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
protected _tabDebounceTimeout?: NodeJS.Timeout;
|
|
29
32
|
|
|
30
33
|
/** Initialize the class */
|
|
31
34
|
protected _init() {
|
|
32
35
|
super._init();
|
|
33
36
|
|
|
34
37
|
this.addEventListener(window, 'keydown', (event) =>
|
|
35
|
-
this._handleKeydown(event)
|
|
38
|
+
this._handleKeydown(event),
|
|
36
39
|
);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/** Check if keyboard events may be ignored */
|
|
40
|
-
|
|
43
|
+
protected _canIgnoreKeyboardEvents() {
|
|
41
44
|
const { activeElement } = document;
|
|
42
45
|
|
|
43
46
|
return (
|
|
@@ -48,7 +51,7 @@ export class SmoothScrollKeyboardPlugin<
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
/** Check if scroll container is in viewport */
|
|
51
|
-
|
|
54
|
+
protected _checkScrollContainerInViewport() {
|
|
52
55
|
const { viewport } = this.app;
|
|
53
56
|
|
|
54
57
|
const bounding = this.component.container.getBoundingClientRect();
|
|
@@ -62,7 +65,7 @@ export class SmoothScrollKeyboardPlugin<
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/** Check if scroll ended */
|
|
65
|
-
|
|
68
|
+
protected _checkIsEndOfScroll() {
|
|
66
69
|
const { component } = this;
|
|
67
70
|
|
|
68
71
|
return (
|
|
@@ -11,8 +11,10 @@ export type { NSplitText };
|
|
|
11
11
|
*/
|
|
12
12
|
export class SplitText<
|
|
13
13
|
StaticProps extends NSplitText.IStaticProps = NSplitText.IStaticProps,
|
|
14
|
-
ChangeableProps extends
|
|
15
|
-
|
|
14
|
+
ChangeableProps extends
|
|
15
|
+
NSplitText.IChangeableProps = NSplitText.IChangeableProps,
|
|
16
|
+
CallbacksTypes extends
|
|
17
|
+
NSplitText.ICallbacksTypes = NSplitText.ICallbacksTypes,
|
|
16
18
|
> extends ComponentClass<StaticProps, ChangeableProps, CallbacksTypes> {
|
|
17
19
|
protected _getDefaultProps() {
|
|
18
20
|
return {
|
|
@@ -31,16 +33,16 @@ export class SplitText<
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** Initial text */
|
|
34
|
-
|
|
36
|
+
protected _initialText: string;
|
|
35
37
|
|
|
36
38
|
/** Initial HTML content */
|
|
37
|
-
|
|
39
|
+
protected _initialHTML: string;
|
|
38
40
|
|
|
39
41
|
/** If the text is already split into letters and words */
|
|
40
|
-
|
|
42
|
+
protected _isBaseSplit: boolean;
|
|
41
43
|
|
|
42
44
|
/** Text container */
|
|
43
|
-
|
|
45
|
+
protected _container: HTMLElement;
|
|
44
46
|
|
|
45
47
|
/** Text container */
|
|
46
48
|
get container() {
|
|
@@ -48,7 +50,7 @@ export class SplitText<
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/** Letters */
|
|
51
|
-
|
|
53
|
+
protected _letters: NSplitText.ILetter[];
|
|
52
54
|
|
|
53
55
|
/** Letters */
|
|
54
56
|
get letters() {
|
|
@@ -56,7 +58,7 @@ export class SplitText<
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/** Words */
|
|
59
|
-
|
|
61
|
+
protected _words: NSplitText.IWord[];
|
|
60
62
|
|
|
61
63
|
/** Words */
|
|
62
64
|
get words() {
|
|
@@ -64,7 +66,7 @@ export class SplitText<
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
/** Lines */
|
|
67
|
-
|
|
69
|
+
protected _lines: NSplitText.ILine[];
|
|
68
70
|
|
|
69
71
|
/** Lines */
|
|
70
72
|
get lines() {
|
|
@@ -88,7 +90,7 @@ export class SplitText<
|
|
|
88
90
|
this._initialText = this._initialText.replace(/\s+\n/gm, '\n');
|
|
89
91
|
this._initialText = this._initialText.replace(
|
|
90
92
|
/<br( ?)(\/?)>/gm,
|
|
91
|
-
String.fromCharCode(10)
|
|
93
|
+
String.fromCharCode(10),
|
|
92
94
|
);
|
|
93
95
|
|
|
94
96
|
// a11y
|
|
@@ -112,7 +114,7 @@ export class SplitText<
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/** Set resize events */
|
|
115
|
-
|
|
117
|
+
protected _setResize() {
|
|
116
118
|
const { viewportTarget, resizeDebounce, hasLines } = this.props;
|
|
117
119
|
|
|
118
120
|
if (!hasLines) {
|
|
@@ -156,7 +158,7 @@ export class SplitText<
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
/** Split the text into words */
|
|
159
|
-
|
|
161
|
+
protected _splitIntoWords() {
|
|
160
162
|
const chars = this._initialText.split('');
|
|
161
163
|
|
|
162
164
|
// create words
|
|
@@ -244,7 +246,7 @@ export class SplitText<
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
/** Split the text into letters */
|
|
247
|
-
|
|
249
|
+
protected _splitIntoLetters() {
|
|
248
250
|
// check if need to have letters
|
|
249
251
|
if (!this.props.hasLetters) {
|
|
250
252
|
return;
|
|
@@ -283,7 +285,7 @@ export class SplitText<
|
|
|
283
285
|
}
|
|
284
286
|
|
|
285
287
|
/** Append split words to the container */
|
|
286
|
-
|
|
288
|
+
protected _appendWords() {
|
|
287
289
|
this._words.forEach((word) => {
|
|
288
290
|
this.container.appendChild(word.element);
|
|
289
291
|
|
|
@@ -298,7 +300,7 @@ export class SplitText<
|
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
/** Split the text into lines */
|
|
301
|
-
|
|
303
|
+
protected _splitIntoLines() {
|
|
302
304
|
// first of all, remove all previous lines
|
|
303
305
|
this._removeLines();
|
|
304
306
|
|
|
@@ -371,7 +373,7 @@ export class SplitText<
|
|
|
371
373
|
}
|
|
372
374
|
|
|
373
375
|
/** Remove all lines */
|
|
374
|
-
|
|
376
|
+
protected _removeLines() {
|
|
375
377
|
this._lines.forEach(({ element }) => element.remove());
|
|
376
378
|
this._lines = [];
|
|
377
379
|
|
|
@@ -9,8 +9,9 @@ export type { NTimeline };
|
|
|
9
9
|
*/
|
|
10
10
|
export class Timeline<
|
|
11
11
|
StaticProps extends NTimeline.IStaticProps = NTimeline.IStaticProps,
|
|
12
|
-
ChangeableProps extends
|
|
13
|
-
|
|
12
|
+
ChangeableProps extends
|
|
13
|
+
NTimeline.IChangeableProps = NTimeline.IChangeableProps,
|
|
14
|
+
CallbacksTypes extends NTimeline.ICallbacksTypes = NTimeline.ICallbacksTypes,
|
|
14
15
|
> extends BaseTimeline<StaticProps, ChangeableProps, CallbacksTypes> {
|
|
15
16
|
protected _getDefaultProps() {
|
|
16
17
|
return {
|
|
@@ -21,10 +22,10 @@ export class Timeline<
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/** The animation frame */
|
|
24
|
-
|
|
25
|
+
protected _animationFrame?: number;
|
|
25
26
|
|
|
26
27
|
/** Last time when animationFrame callback has been called */
|
|
27
|
-
|
|
28
|
+
protected _animationFrameLastTime: number;
|
|
28
29
|
|
|
29
30
|
/** Timeline is playing */
|
|
30
31
|
get isPlaying() {
|
|
@@ -32,7 +33,7 @@ export class Timeline<
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/** Timeline is reversed */
|
|
35
|
-
|
|
36
|
+
protected _isReversed: boolean;
|
|
36
37
|
|
|
37
38
|
/** Timeline is reversed */
|
|
38
39
|
get isReversed() {
|
|
@@ -40,7 +41,7 @@ export class Timeline<
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/** Timeline is paused */
|
|
43
|
-
|
|
44
|
+
protected _isPaused: boolean;
|
|
44
45
|
|
|
45
46
|
/** Timeline is paused */
|
|
46
47
|
get isPaused() {
|
|
@@ -116,7 +117,7 @@ export class Timeline<
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/** Start animation */
|
|
119
|
-
|
|
120
|
+
protected _animate() {
|
|
120
121
|
if (this.isPaused) {
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
@@ -148,7 +149,7 @@ export class Timeline<
|
|
|
148
149
|
|
|
149
150
|
// continue animation
|
|
150
151
|
this._animationFrame = window.requestAnimationFrame(
|
|
151
|
-
this._animate.bind(this)
|
|
152
|
+
this._animate.bind(this),
|
|
152
153
|
);
|
|
153
154
|
}
|
|
154
155
|
|
package/src/components/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './ProgressPreloader';
|
|
|
11
11
|
export * from './ScrollBar';
|
|
12
12
|
export * from './ScrollView';
|
|
13
13
|
export * from './SectionScrollProgress';
|
|
14
|
+
export * from './SlideProgress';
|
|
14
15
|
export * from './SmoothScroll';
|
|
15
16
|
export * from './SmoothScrollDragPlugin';
|
|
16
17
|
export * from './SmoothScrollKeyboardPlugin';
|