vevet 2.4.0 → 2.6.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/build/cdn/index.js +1 -1
- package/build/cjs/components/scroll/scrollable/ScrollView.js +2 -2
- package/build/cjs/components/scroll/section/ScrollSectionProgress.js +261 -0
- package/build/cjs/index.js +3 -1
- package/build/es/components/scroll/scrollable/ScrollView.js +2 -2
- package/build/es/components/scroll/section/ScrollSectionProgress.js +181 -0
- package/build/es/index.js +2 -1
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +6 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
- package/build/types/components/scroll/section/ScrollSectionProgress.d.ts +131 -0
- package/build/types/components/scroll/section/ScrollSectionProgress.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ts/components/scroll/scrollable/ScrollView.ts +8 -1
- package/src/ts/components/scroll/section/ScrollSectionProgress.ts +344 -0
- package/src/ts/index.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollSectionProgress.d.ts","sourceRoot":"","sources":["../../../../../src/ts/components/scroll/section/ScrollSectionProgress.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,eAAe,MAAM,uCAAuC,CAAC;AAIpE,yBAAiB,sBAAsB,CAAC;IAEpC;;OAEG;IACH,UAAiB,UAAW,SAAQ,UAAU,CAAC,UAAU;QAC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,CAAC;IACzC,IAAI,WAAW,qBAEd;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,SAAS,KAAK,OAAO,qBAEpB;IAED;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,SAAS,qBAEZ;IAED;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,IAAI,QAAQ,qBAEX;IAED,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,IAAI,QAAQ,WAEX;IACD,IAAI,QAAQ,CAAE,GAAG,QAAA,EAEhB;gBAKG,WAAW,CAAC,EAAE,CAAC,UAAU,GAAG,cAAc,CAAC,EAC3C,IAAI,UAAO;IA+BR,IAAI;IAKX,SAAS,CAAC,UAAU;IAuBpB,SAAS,CAAC,aAAa;IAOvB;;OAEG;IACH,IAAI,UAAU,WAKb;IAED;;OAEG;IACH,IAAI,WAAW,WAKd;IAED;;OAEG;IACH,IAAI,YAAY,WAKf;IAID;;OAEG;IACH,SAAS,CAAC,aAAa;IAWvB;;OAEG;IACI,MAAM;IA6Bb;;OAEG;IACH,SAAS,CAAC,OAAO,CACb,UAAU,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,EAC9C,KAAK,UAAQ;IASjB;;OAEG;IACH,SAAS,CAAC,UAAU,CAChB,UAAU,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,EAC9C,KAAK,UAAQ;IAkBjB;;OAEG;IACH,SAAS,CAAC,QAAQ;CAKrB"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { ScrollEventsBase, NScrollEventsBase } from './components/scroll/scrolla
|
|
|
29
29
|
import { ScrollView, NScrollView } from './components/scroll/scrollable/ScrollView';
|
|
30
30
|
import { SmoothScrollKeyboardPlugin, NSmoothScrollKeyboardPlugin } from './components/scroll/plugins/SmoothScrollKeyboardPlugin';
|
|
31
31
|
import { SmoothScrollDragPlugin, NSmoothScrollDragPlugin } from './components/scroll/plugins/SmoothScrollDragPlugin';
|
|
32
|
+
import { ScrollSectionProgress, NScrollSectionProgress } from './components/scroll/section/ScrollSectionProgress';
|
|
32
33
|
import { SplitText, NSplitText } from './components/text/SplitText';
|
|
33
34
|
import { CustomCursor, NCustomCursor } from './components/cursor/CustomCursor';
|
|
34
35
|
declare const utils: {
|
|
@@ -37,5 +38,5 @@ declare const utils: {
|
|
|
37
38
|
math: typeof math;
|
|
38
39
|
scroll: typeof scroll;
|
|
39
40
|
};
|
|
40
|
-
export { utils, GeneralTypes, Application, NApplication, Viewport, NViewport, PageLoad, NPageLoad, Callbacks, NCallbacks, MutableProp, NMutableProp, Module, NModule, Component, NComponent, Plugin, NPlugin, Page, NPage, WheelHandler, NWheelHandler, AnimationFrame, NAnimationFrame, StaticTimeline, NStaticTimeline, Timeline, NTimeline, Preloader, NPreloader, ProgressPreloader, NProgressPreloader, Dragger, NDragger, DraggerMove, NDraggerMove, DraggerDirection, NDraggerDirection, Ctx2D, NCtx2D, Ctx2DPrerender, NCtx2DPrerender, SmoothScroll, NSmoothScroll, ScrollBar, NScrollBar, ScrollEventsBase, NScrollEventsBase, ScrollView, NScrollView, SmoothScrollKeyboardPlugin, NSmoothScrollKeyboardPlugin, SmoothScrollDragPlugin, NSmoothScrollDragPlugin, SplitText, NSplitText, CustomCursor, NCustomCursor, };
|
|
41
|
+
export { utils, GeneralTypes, Application, NApplication, Viewport, NViewport, PageLoad, NPageLoad, Callbacks, NCallbacks, MutableProp, NMutableProp, Module, NModule, Component, NComponent, Plugin, NPlugin, Page, NPage, WheelHandler, NWheelHandler, AnimationFrame, NAnimationFrame, StaticTimeline, NStaticTimeline, Timeline, NTimeline, Preloader, NPreloader, ProgressPreloader, NProgressPreloader, Dragger, NDragger, DraggerMove, NDraggerMove, DraggerDirection, NDraggerDirection, Ctx2D, NCtx2D, Ctx2DPrerender, NCtx2DPrerender, SmoothScroll, NSmoothScroll, ScrollBar, NScrollBar, ScrollEventsBase, NScrollEventsBase, ScrollView, NScrollView, SmoothScrollKeyboardPlugin, NSmoothScrollKeyboardPlugin, SmoothScrollDragPlugin, NSmoothScrollDragPlugin, ScrollSectionProgress, NScrollSectionProgress, SplitText, NSplitText, CustomCursor, NCustomCursor, };
|
|
41
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CA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AAY,EACzB,gBAAgB,EAAE,iBAAiB,EAEnC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,eAAe,EAE/B,YAAY,EAAE,aAAa,EAC3B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,iBAAiB,EACnC,UAAU,EAAE,WAAW,EACvB,0BAA0B,EAAE,2BAA2B,EACvD,sBAAsB,EAAE,uBAAuB,EAC/C,qBAAqB,EAAE,sBAAsB,EAE7C,SAAS,EAAE,UAAU,EAErB,YAAY,EAAE,aAAa,GAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import onScroll from '../../../utils/listeners/onScroll';
|
|
|
5
5
|
import { intersectionObserverSupported } from '../../../utils/listeners';
|
|
6
6
|
import clamp from '../../../utils/math/clamp';
|
|
7
7
|
import timeoutCallback from '../../../utils/common/timeoutCallback';
|
|
8
|
+
import { NViewport } from '../../../app/events/Viewport';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -55,6 +56,11 @@ export namespace NScrollView {
|
|
|
55
56
|
* @default true
|
|
56
57
|
*/
|
|
57
58
|
useIntersectionObserver?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Viewport target on resize
|
|
61
|
+
* @default ''
|
|
62
|
+
*/
|
|
63
|
+
viewportTarget?: keyof NViewport.CallbacksTypes;
|
|
58
64
|
/**
|
|
59
65
|
* @default 0
|
|
60
66
|
*/
|
|
@@ -114,6 +120,7 @@ export class ScrollView <
|
|
|
114
120
|
classToToggle: 'viewed',
|
|
115
121
|
useDelay: false,
|
|
116
122
|
useIntersectionObserver: true,
|
|
123
|
+
viewportTarget: '',
|
|
117
124
|
resizeTimeout: 0,
|
|
118
125
|
};
|
|
119
126
|
}
|
|
@@ -174,7 +181,7 @@ export class ScrollView <
|
|
|
174
181
|
protected _setEvents () {
|
|
175
182
|
super._setEvents();
|
|
176
183
|
this.resize();
|
|
177
|
-
this.addViewportCallback(
|
|
184
|
+
this.addViewportCallback(this.prop.viewportTarget, () => {
|
|
178
185
|
this.resize();
|
|
179
186
|
}, {
|
|
180
187
|
timeout: this.prop.resizeTimeout,
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { selectOne } from 'vevet-dom';
|
|
2
|
+
import PCancelable from 'p-cancelable';
|
|
3
|
+
import { IRemovable } from '../../../utils/types/general';
|
|
4
|
+
import { RequiredModuleProp } from '../../../utils/types/utility';
|
|
5
|
+
import onScroll from '../../../utils/listeners/onScroll';
|
|
6
|
+
import { Component, NComponent } from '../../../base/Component';
|
|
7
|
+
import { NViewport } from '../../../app/events/Viewport';
|
|
8
|
+
import { SmoothScroll } from '../smooth-scroll/SmoothScroll';
|
|
9
|
+
import clampScope from '../../../utils/math/clampScope';
|
|
10
|
+
import getScrollValues from '../../../utils/scroll/getScrollValues';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export namespace NScrollSectionProgress {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Static properties
|
|
18
|
+
*/
|
|
19
|
+
export interface StaticProp extends NComponent.StaticProp {
|
|
20
|
+
/**
|
|
21
|
+
* The scrollable container
|
|
22
|
+
* @default window
|
|
23
|
+
*/
|
|
24
|
+
container?: string | Element | SmoothScroll | Window;
|
|
25
|
+
/**
|
|
26
|
+
* The scrollable element
|
|
27
|
+
*/
|
|
28
|
+
section: string | Element;
|
|
29
|
+
/**
|
|
30
|
+
* Viewport target on resize
|
|
31
|
+
* @default ''
|
|
32
|
+
*/
|
|
33
|
+
viewportTarget?: keyof NViewport.CallbacksTypes;
|
|
34
|
+
/**
|
|
35
|
+
* @default 0
|
|
36
|
+
*/
|
|
37
|
+
resizeTimeout?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Changeable properties
|
|
42
|
+
*/
|
|
43
|
+
export interface ChangeableProp extends NComponent.ChangeableProp { }
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Available callbacks
|
|
47
|
+
*/
|
|
48
|
+
export interface CallbacksTypes extends NComponent.CallbacksTypes {
|
|
49
|
+
'render': false;
|
|
50
|
+
'resize': false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Elements into viewport
|
|
59
|
+
*/
|
|
60
|
+
export class ScrollSectionProgress <
|
|
61
|
+
StaticProp extends NScrollSectionProgress.StaticProp
|
|
62
|
+
= NScrollSectionProgress.StaticProp,
|
|
63
|
+
ChangeableProp extends NScrollSectionProgress.ChangeableProp
|
|
64
|
+
= NScrollSectionProgress.ChangeableProp,
|
|
65
|
+
CallbacksTypes extends NScrollSectionProgress.CallbacksTypes
|
|
66
|
+
= NScrollSectionProgress.CallbacksTypes,
|
|
67
|
+
> extends Component <
|
|
68
|
+
StaticProp,
|
|
69
|
+
ChangeableProp,
|
|
70
|
+
CallbacksTypes
|
|
71
|
+
> {
|
|
72
|
+
protected _getDefaultProp <
|
|
73
|
+
T extends RequiredModuleProp<StaticProp & ChangeableProp>
|
|
74
|
+
> (): T {
|
|
75
|
+
return {
|
|
76
|
+
...super._getDefaultProp(),
|
|
77
|
+
container: window,
|
|
78
|
+
viewportTarget: '',
|
|
79
|
+
resizeTimeout: 0,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Scroll container
|
|
85
|
+
*/
|
|
86
|
+
protected _scrollContainer: Element | SmoothScroll | Window;
|
|
87
|
+
get scrollContainer () {
|
|
88
|
+
return this._scrollContainer;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Section element
|
|
93
|
+
*/
|
|
94
|
+
protected _section: Element;
|
|
95
|
+
get section () {
|
|
96
|
+
return this._section;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Scroll event
|
|
101
|
+
*/
|
|
102
|
+
protected _scrollEvent?: IRemovable;
|
|
103
|
+
/**
|
|
104
|
+
* Loaded event
|
|
105
|
+
*/
|
|
106
|
+
protected _loadedEvent?: PCancelable<any>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Scrolling scope
|
|
110
|
+
*/
|
|
111
|
+
protected _scopeScroll: [number, number];
|
|
112
|
+
get scopeScroll () {
|
|
113
|
+
return this._scopeScroll;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 'In' scope relative to the global progress
|
|
118
|
+
*/
|
|
119
|
+
protected _scopeIn: [number, number];
|
|
120
|
+
protected get scopeIn () {
|
|
121
|
+
return this._scopeIn;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 'Move' scope relative to the global progress
|
|
126
|
+
*/
|
|
127
|
+
protected _scopeMove: [number, number];
|
|
128
|
+
get scopeMove () {
|
|
129
|
+
return this._scopeMove;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 'Move' scope relative to the global progress
|
|
134
|
+
*/
|
|
135
|
+
protected _scopeOut: [number, number];
|
|
136
|
+
get scopeOut () {
|
|
137
|
+
return this._scopeOut;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
protected _progress: number;
|
|
141
|
+
/**
|
|
142
|
+
* Global progress
|
|
143
|
+
*/
|
|
144
|
+
get progress () {
|
|
145
|
+
return this._progress;
|
|
146
|
+
}
|
|
147
|
+
set progress (val) {
|
|
148
|
+
this._progress = val;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
constructor (
|
|
154
|
+
initialProp?: (StaticProp & ChangeableProp),
|
|
155
|
+
init = true,
|
|
156
|
+
) {
|
|
157
|
+
super(initialProp, false);
|
|
158
|
+
|
|
159
|
+
// get scroll container
|
|
160
|
+
if (typeof this.prop.container === 'string') {
|
|
161
|
+
this._scrollContainer = selectOne(this.prop.container) as Element;
|
|
162
|
+
} else {
|
|
163
|
+
this._scrollContainer = this.prop.container;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// get section element
|
|
167
|
+
if (typeof this.prop.section === 'string') {
|
|
168
|
+
this._section = selectOne(this.prop.section) as Element;
|
|
169
|
+
} else {
|
|
170
|
+
this._section = this.prop.section;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// set defaults
|
|
174
|
+
this._progress = -0.001;
|
|
175
|
+
this._scopeScroll = [0, 0];
|
|
176
|
+
this._scopeIn = [0, 0];
|
|
177
|
+
this._scopeMove = [0, 0];
|
|
178
|
+
this._scopeOut = [0, 0];
|
|
179
|
+
|
|
180
|
+
// initialize the class
|
|
181
|
+
if (init) {
|
|
182
|
+
this.init();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public init () {
|
|
187
|
+
super.init();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Set Module Events
|
|
191
|
+
protected _setEvents () {
|
|
192
|
+
super._setEvents();
|
|
193
|
+
|
|
194
|
+
// set resize events
|
|
195
|
+
this.addViewportCallback(this.prop.viewportTarget, () => {
|
|
196
|
+
this.resize();
|
|
197
|
+
}, {
|
|
198
|
+
timeout: this.prop.resizeTimeout,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// resize on page loaded
|
|
202
|
+
this._loadedEvent = this._app.onPageLoaded();
|
|
203
|
+
this._loadedEvent.then(() => {
|
|
204
|
+
this.resize();
|
|
205
|
+
}).catch(() => {});
|
|
206
|
+
|
|
207
|
+
// set scroll events
|
|
208
|
+
this._scrollEvent = onScroll({
|
|
209
|
+
container: this.prop.container,
|
|
210
|
+
callback: this._handleScroll.bind(this),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
protected _onPropMutate () {
|
|
215
|
+
super._onPropMutate();
|
|
216
|
+
this.resize();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 'in' progress
|
|
223
|
+
*/
|
|
224
|
+
get progressIn () {
|
|
225
|
+
return clampScope(
|
|
226
|
+
this.progress,
|
|
227
|
+
this.scopeIn,
|
|
228
|
+
) || 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 'out' progress
|
|
233
|
+
*/
|
|
234
|
+
get progressOut () {
|
|
235
|
+
return clampScope(
|
|
236
|
+
this.progress,
|
|
237
|
+
this.scopeOut,
|
|
238
|
+
) || 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 'move' progress
|
|
243
|
+
*/
|
|
244
|
+
get progressMove () {
|
|
245
|
+
return clampScope(
|
|
246
|
+
this.progress,
|
|
247
|
+
this.scopeMove,
|
|
248
|
+
) || 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Handle scroll event
|
|
255
|
+
*/
|
|
256
|
+
protected _handleScroll () {
|
|
257
|
+
// calculate scopes
|
|
258
|
+
const scrollData = getScrollValues(this.scrollContainer);
|
|
259
|
+
if (!scrollData) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
this._render(scrollData);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Resize the scene
|
|
269
|
+
*/
|
|
270
|
+
public resize () {
|
|
271
|
+
// calculate scopes
|
|
272
|
+
const scrollData = getScrollValues(this.scrollContainer);
|
|
273
|
+
if (!scrollData) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// get sizes
|
|
278
|
+
const bounding = this.section.getBoundingClientRect();
|
|
279
|
+
const vHeight = this._app.viewport.height;
|
|
280
|
+
|
|
281
|
+
// calculate scroll scope
|
|
282
|
+
const inStart = scrollData.scrollTop + bounding.top - vHeight;
|
|
283
|
+
const moveEnd = scrollData.scrollTop + bounding.top + bounding.height;
|
|
284
|
+
const scrollLine = moveEnd - inStart;
|
|
285
|
+
this._scopeScroll = [inStart, moveEnd];
|
|
286
|
+
|
|
287
|
+
// calculate scopes
|
|
288
|
+
this._scopeIn = [0, vHeight / scrollLine];
|
|
289
|
+
this._scopeOut = [1 - vHeight / scrollLine, 1];
|
|
290
|
+
this._scopeMove = [this._scopeIn[1], this._scopeOut[0]];
|
|
291
|
+
|
|
292
|
+
// launch callbacks
|
|
293
|
+
this.callbacks.tbt('resize', false);
|
|
294
|
+
|
|
295
|
+
// render the scene
|
|
296
|
+
this._render(scrollData, true);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Render the scene
|
|
301
|
+
*/
|
|
302
|
+
protected _render (
|
|
303
|
+
scrollData: ReturnType<typeof getScrollValues>,
|
|
304
|
+
force = false,
|
|
305
|
+
) {
|
|
306
|
+
const canRender = this._canRender(scrollData, force);
|
|
307
|
+
if (!canRender) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.callbacks.tbt('render', false);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Check if the section can be rendered
|
|
315
|
+
*/
|
|
316
|
+
protected _canRender (
|
|
317
|
+
scrollData: ReturnType<typeof getScrollValues>,
|
|
318
|
+
force = false,
|
|
319
|
+
) {
|
|
320
|
+
if (!scrollData) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
const { scrollTop } = scrollData;
|
|
324
|
+
const prevProgress = this.progress;
|
|
325
|
+
|
|
326
|
+
const progress = clampScope(
|
|
327
|
+
scrollTop,
|
|
328
|
+
[this._scopeScroll[0], this._scopeScroll[1]],
|
|
329
|
+
) || 0;
|
|
330
|
+
this.progress = progress;
|
|
331
|
+
|
|
332
|
+
return force || (progress !== prevProgress);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Destroy the module
|
|
338
|
+
*/
|
|
339
|
+
protected _destroy () {
|
|
340
|
+
super._destroy();
|
|
341
|
+
this._scrollEvent?.remove();
|
|
342
|
+
this._loadedEvent?.cancel();
|
|
343
|
+
}
|
|
344
|
+
}
|
package/src/ts/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { ScrollEventsBase, NScrollEventsBase } from './components/scroll/scrolla
|
|
|
40
40
|
import { ScrollView, NScrollView } from './components/scroll/scrollable/ScrollView';
|
|
41
41
|
import { SmoothScrollKeyboardPlugin, NSmoothScrollKeyboardPlugin } from './components/scroll/plugins/SmoothScrollKeyboardPlugin';
|
|
42
42
|
import { SmoothScrollDragPlugin, NSmoothScrollDragPlugin } from './components/scroll/plugins/SmoothScrollDragPlugin';
|
|
43
|
+
import { ScrollSectionProgress, NScrollSectionProgress } from './components/scroll/section/ScrollSectionProgress';
|
|
43
44
|
|
|
44
45
|
import { SplitText, NSplitText } from './components/text/SplitText';
|
|
45
46
|
|
|
@@ -93,6 +94,7 @@ export {
|
|
|
93
94
|
ScrollView, NScrollView,
|
|
94
95
|
SmoothScrollKeyboardPlugin, NSmoothScrollKeyboardPlugin,
|
|
95
96
|
SmoothScrollDragPlugin, NSmoothScrollDragPlugin,
|
|
97
|
+
ScrollSectionProgress, NScrollSectionProgress,
|
|
96
98
|
|
|
97
99
|
SplitText, NSplitText,
|
|
98
100
|
|