vevet 1.4.27 → 2.0.1-dev.3
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/LICENSE +1 -1
- package/README.md +7 -71
- package/build/cdn/index.js +12 -0
- package/build/cdn/index.js.LICENSE.txt +14 -0
- package/build/cjs/app/Application.js +297 -0
- package/build/cjs/app/events/PageLoad.js +74 -0
- package/build/cjs/app/events/Viewport.js +303 -0
- package/build/cjs/base/Callbacks.js +232 -0
- package/build/cjs/base/Component.js +56 -0
- package/build/cjs/base/Module.js +262 -0
- package/build/cjs/base/MutableProp.js +165 -0
- package/build/cjs/base/Plugin.js +56 -0
- package/build/cjs/components/animation-frame/AnimationFrame.js +183 -0
- package/build/cjs/components/canvas/Ctx2D.js +200 -0
- package/build/cjs/components/canvas/Ctx2DPrerender.js +72 -0
- package/build/cjs/components/cursor/CustomCursor.js +344 -0
- package/build/cjs/components/dragger/Dragger.js +229 -0
- package/build/cjs/components/dragger/DraggerDirection.js +77 -0
- package/build/cjs/components/dragger/DraggerMove.js +84 -0
- package/build/cjs/components/loading/Preloader.js +229 -0
- package/build/cjs/components/loading/ProgressPreloader.js +377 -0
- package/build/cjs/components/page/Page.js +353 -0
- package/build/cjs/components/scroll/custom-scroll/CustomScroll.js +517 -0
- package/build/cjs/components/scroll/plugins/SmoothScrollDragPlugin.js +178 -0
- package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +138 -0
- package/build/cjs/components/scroll/scrollable/ScrollEventsBase.js +133 -0
- package/build/cjs/components/scroll/scrollable/ScrollView.js +315 -0
- package/build/cjs/components/scroll/scrollbar/Bar.js +315 -0
- package/build/cjs/components/scroll/scrollbar/ScrollBar.js +206 -0
- package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +625 -0
- package/build/cjs/components/scroll/types.js +2 -0
- package/build/cjs/components/split-text/SplitText.js +233 -0
- package/build/cjs/components/text/SplitText.js +329 -0
- package/build/cjs/components/timeline/StaticTimeline.js +137 -0
- package/build/cjs/components/timeline/Timeline.js +190 -0
- package/build/cjs/index.js +87 -0
- package/build/cjs/utils/common/index.js +12 -0
- package/build/cjs/utils/common/mergeWithoutArrays.js +19 -0
- package/build/cjs/utils/common/randID.js +11 -0
- package/build/cjs/utils/common/timeoutCallback.js +17 -0
- package/build/cjs/utils/errors.js +8 -0
- package/build/cjs/utils/listeners/index.js +10 -0
- package/build/cjs/utils/listeners/intersectionObserverSupported.js +11 -0
- package/build/cjs/utils/listeners/onScroll.js +47 -0
- package/build/cjs/utils/math/boundVal.js +16 -0
- package/build/cjs/utils/math/index.js +12 -0
- package/build/cjs/utils/math/lerp.js +15 -0
- package/build/cjs/utils/math/scopeProgress.js +25 -0
- package/build/cjs/utils/types/general.js +2 -0
- package/build/cjs/utils/types/utility.js +2 -0
- package/build/es/app/Application.js +210 -0
- package/build/es/app/events/PageLoad.js +47 -0
- package/build/es/app/events/Viewport.js +232 -0
- package/build/es/base/Callbacks.js +205 -0
- package/build/es/base/Component.js +32 -0
- package/build/es/base/Module.js +225 -0
- package/build/es/base/MutableProp.js +152 -0
- package/build/es/base/Plugin.js +31 -0
- package/build/es/components/animation-frame/AnimationFrame.js +145 -0
- package/build/es/components/canvas/Ctx2D.js +133 -0
- package/build/es/components/canvas/Ctx2DPrerender.js +37 -0
- package/build/es/components/cursor/CustomCursor.js +274 -0
- package/build/es/components/dragger/Dragger.js +175 -0
- package/build/es/components/dragger/DraggerDirection.js +42 -0
- package/build/es/components/dragger/DraggerMove.js +56 -0
- package/build/es/components/loading/Preloader.js +164 -0
- package/build/es/components/loading/ProgressPreloader.js +304 -0
- package/build/es/components/page/Page.js +283 -0
- package/build/es/components/scroll/custom-scroll/CustomScroll.js +486 -0
- package/build/es/components/scroll/plugins/SmoothScrollDragPlugin.js +140 -0
- package/build/es/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +109 -0
- package/build/es/components/scroll/scrollable/ScrollEventsBase.js +79 -0
- package/build/es/components/scroll/scrollable/ScrollView.js +264 -0
- package/build/es/components/scroll/scrollbar/Bar.js +262 -0
- package/build/es/components/scroll/scrollbar/ScrollBar.js +152 -0
- package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +519 -0
- package/build/es/components/scroll/types.js +1 -0
- package/build/es/components/split-text/SplitText.js +199 -0
- package/build/es/components/text/SplitText.js +270 -0
- package/build/es/components/timeline/StaticTimeline.js +92 -0
- package/build/es/components/timeline/Timeline.js +141 -0
- package/build/es/index.js +37 -0
- package/build/es/utils/common/index.js +4 -0
- package/build/es/utils/common/mergeWithoutArrays.js +13 -0
- package/build/es/utils/common/randID.js +7 -0
- package/build/es/utils/common/timeoutCallback.js +14 -0
- package/build/es/utils/errors.js +5 -0
- package/build/es/utils/listeners/index.js +3 -0
- package/build/es/utils/listeners/intersectionObserverSupported.js +8 -0
- package/build/es/utils/listeners/onScroll.js +44 -0
- package/build/es/utils/math/boundVal.js +12 -0
- package/build/es/utils/math/index.js +4 -0
- package/build/es/utils/math/lerp.js +11 -0
- package/build/es/utils/math/scopeProgress.js +22 -0
- package/build/es/utils/types/general.js +1 -0
- package/build/es/utils/types/utility.js +1 -0
- package/build/types/app/Application.d.ts +161 -0
- package/build/types/app/Application.d.ts.map +1 -0
- package/build/types/app/events/PageLoad.d.ts +28 -0
- package/build/types/app/events/PageLoad.d.ts.map +1 -0
- package/build/types/app/events/Viewport.d.ts +137 -0
- package/build/types/app/events/Viewport.d.ts.map +1 -0
- package/build/types/base/Callbacks.d.ts +174 -0
- package/build/types/base/Callbacks.d.ts.map +1 -0
- package/build/types/base/Component.d.ts +48 -0
- package/build/types/base/Component.d.ts.map +1 -0
- package/build/types/base/Module.d.ts +179 -0
- package/build/types/base/Module.d.ts.map +1 -0
- package/build/types/base/MutableProp.d.ts +142 -0
- package/build/types/base/MutableProp.d.ts.map +1 -0
- package/build/types/base/Plugin.d.ts +35 -0
- package/build/types/base/Plugin.d.ts.map +1 -0
- package/build/types/components/animation-frame/AnimationFrame.d.ts +96 -0
- package/build/types/components/animation-frame/AnimationFrame.d.ts.map +1 -0
- package/build/types/components/canvas/Ctx2D.d.ts +111 -0
- package/build/types/components/canvas/Ctx2D.d.ts.map +1 -0
- package/build/types/components/canvas/Ctx2DPrerender.d.ts +41 -0
- package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -0
- package/build/types/components/cursor/CustomCursor.d.ts +181 -0
- package/build/types/components/cursor/CustomCursor.d.ts.map +1 -0
- package/build/types/components/dragger/Dragger.d.ts +120 -0
- package/build/types/components/dragger/Dragger.d.ts.map +1 -0
- package/build/types/components/dragger/DraggerDirection.d.ts +39 -0
- package/build/types/components/dragger/DraggerDirection.d.ts.map +1 -0
- package/build/types/components/dragger/DraggerMove.d.ts +49 -0
- package/build/types/components/dragger/DraggerMove.d.ts.map +1 -0
- package/build/types/components/loading/Preloader.d.ts +107 -0
- package/build/types/components/loading/Preloader.d.ts.map +1 -0
- package/build/types/components/loading/ProgressPreloader.d.ts +166 -0
- package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -0
- package/build/types/components/page/Page.d.ts +126 -0
- package/build/types/components/page/Page.d.ts.map +1 -0
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts +322 -0
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts.map +1 -0
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts +97 -0
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts.map +1 -0
- package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts +34 -0
- package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts.map +1 -0
- package/build/types/components/scroll/scrollable/ScrollEventsBase.d.ts +60 -0
- package/build/types/components/scroll/scrollable/ScrollEventsBase.d.ts.map +1 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +140 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -0
- package/build/types/components/scroll/scrollbar/Bar.d.ts +84 -0
- package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -0
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts +109 -0
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts.map +1 -0
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts +307 -0
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -0
- package/build/types/components/scroll/types.d.ts +11 -0
- package/build/types/components/scroll/types.d.ts.map +1 -0
- package/build/types/components/split-text/SplitText.d.ts +118 -0
- package/build/types/components/split-text/SplitText.d.ts.map +1 -0
- package/build/types/components/text/SplitText.d.ts +118 -0
- package/build/types/components/text/SplitText.d.ts.map +1 -0
- package/build/types/components/timeline/StaticTimeline.d.ts +92 -0
- package/build/types/components/timeline/StaticTimeline.d.ts.map +1 -0
- package/build/types/components/timeline/Timeline.d.ts +101 -0
- package/build/types/components/timeline/Timeline.d.ts.map +1 -0
- package/build/types/index.d.ts +38 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/utils/common/index.d.ts +5 -0
- package/build/types/utils/common/index.d.ts.map +1 -0
- package/build/types/utils/common/mergeWithoutArrays.d.ts +6 -0
- package/build/types/utils/common/mergeWithoutArrays.d.ts.map +1 -0
- package/build/types/utils/common/randID.d.ts +5 -0
- package/build/types/utils/common/randID.d.ts.map +1 -0
- package/build/types/utils/common/timeoutCallback.d.ts +6 -0
- package/build/types/utils/common/timeoutCallback.d.ts.map +1 -0
- package/build/types/utils/errors.d.ts +3 -0
- package/build/types/utils/errors.d.ts.map +1 -0
- package/build/types/utils/listeners/index.d.ts +4 -0
- package/build/types/utils/listeners/index.d.ts.map +1 -0
- package/build/types/utils/listeners/intersectionObserverSupported.d.ts +2 -0
- package/build/types/utils/listeners/intersectionObserverSupported.d.ts.map +1 -0
- package/build/types/utils/listeners/onScroll.d.ts +10 -0
- package/build/types/utils/listeners/onScroll.d.ts.map +1 -0
- package/build/types/utils/math/boundVal.d.ts +5 -0
- package/build/types/utils/math/boundVal.d.ts.map +1 -0
- package/build/types/utils/math/index.d.ts +5 -0
- package/build/types/utils/math/index.d.ts.map +1 -0
- package/build/types/utils/math/lerp.d.ts +5 -0
- package/build/types/utils/math/lerp.d.ts.map +1 -0
- package/build/types/utils/math/scopeProgress.d.ts +20 -0
- package/build/types/utils/math/scopeProgress.d.ts.map +1 -0
- package/build/types/utils/types/general.d.ts +7 -0
- package/build/types/utils/types/general.d.ts.map +1 -0
- package/build/types/utils/types/utility.d.ts +14 -0
- package/build/types/utils/types/utility.d.ts.map +1 -0
- package/package.json +88 -82
- package/src/cdn/index.js +3 -0
- package/src/sass/base.scss +3 -0
- package/src/sass/components/cursor/_custom-cursor.scss +63 -0
- package/src/sass/components/index.scss +6 -0
- package/src/sass/components/loading/_preloader.scss +15 -0
- package/src/sass/components/scroll/_scrollbar.scss +73 -0
- package/src/sass/components/scroll/_smooth-scroll.scss +17 -0
- package/src/sass/index.scss +3 -0
- package/src/sass/mixins/_scroll.scss +7 -0
- package/{dist/scss → src/sass}/mixins/_transition.scss +8 -4
- package/src/sass/mixins/_viewport.scss +69 -0
- package/src/sass/mixins/index.scss +3 -0
- package/src/ts/app/Application.ts +350 -0
- package/src/ts/app/events/PageLoad.ts +79 -0
- package/src/ts/app/events/Viewport.ts +365 -0
- package/src/ts/base/Callbacks.ts +380 -0
- package/src/ts/base/Component.ts +83 -0
- package/src/ts/base/Module.ts +385 -0
- package/src/ts/base/MutableProp.ts +242 -0
- package/src/ts/base/Plugin.ts +76 -0
- package/src/ts/components/animation-frame/AnimationFrame.ts +264 -0
- package/src/ts/components/canvas/Ctx2D.ts +260 -0
- package/src/ts/components/canvas/Ctx2DPrerender.ts +96 -0
- package/src/ts/components/cursor/CustomCursor.ts +462 -0
- package/src/ts/components/dragger/Dragger.ts +313 -0
- package/src/ts/components/dragger/DraggerDirection.ts +106 -0
- package/src/ts/components/dragger/DraggerMove.ts +114 -0
- package/src/ts/components/loading/Preloader.ts +279 -0
- package/src/ts/components/loading/ProgressPreloader.ts +484 -0
- package/src/ts/components/page/Page.ts +421 -0
- package/src/ts/components/scroll/plugins/SmoothScrollDragPlugin.ts +251 -0
- package/src/ts/components/scroll/plugins/SmoothScrollKeyboardPlugin.ts +166 -0
- package/src/ts/components/scroll/scrollable/ScrollEventsBase.ts +151 -0
- package/src/ts/components/scroll/scrollable/ScrollView.ts +435 -0
- package/src/ts/components/scroll/scrollbar/Bar.ts +364 -0
- package/src/ts/components/scroll/scrollbar/ScrollBar.ts +292 -0
- package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +861 -0
- package/src/ts/components/scroll/types.ts +10 -0
- package/src/ts/components/text/SplitText.ts +418 -0
- package/src/ts/components/timeline/StaticTimeline.ts +197 -0
- package/src/ts/components/timeline/Timeline.ts +256 -0
- package/src/ts/index.ts +94 -0
- package/src/ts/utils/common/index.ts +9 -0
- package/src/ts/utils/common/mergeWithoutArrays.ts +20 -0
- package/src/ts/utils/common/randID.ts +9 -0
- package/src/ts/utils/common/timeoutCallback.ts +16 -0
- package/src/ts/utils/errors.ts +6 -0
- package/src/ts/utils/listeners/index.ts +7 -0
- package/src/ts/utils/listeners/intersectionObserverSupported.ts +10 -0
- package/src/ts/utils/listeners/onScroll.ts +56 -0
- package/src/ts/utils/math/boundVal.ts +15 -0
- package/src/ts/utils/math/index.ts +9 -0
- package/src/ts/utils/math/lerp.ts +16 -0
- package/src/ts/utils/math/scopeProgress.ts +23 -0
- package/src/ts/utils/types/general.ts +7 -0
- package/src/ts/utils/types/utility.ts +34 -0
- package/dist/js/AJAXEvent.js +0 -355
- package/dist/js/Application.js +0 -345
- package/dist/js/ColumnsModule.js +0 -392
- package/dist/js/CursorModule.js +0 -390
- package/dist/js/DraggerModule.js +0 -792
- package/dist/js/Event.js +0 -538
- package/dist/js/FilterModule.js +0 -943
- package/dist/js/FormModule.js +0 -706
- package/dist/js/FrameModule.js +0 -229
- package/dist/js/IntervalModule.js +0 -270
- package/dist/js/KeydownModule.js +0 -293
- package/dist/js/LoadEvent.js +0 -106
- package/dist/js/MenuBaseModule.js +0 -292
- package/dist/js/MenuModule.js +0 -265
- package/dist/js/MenuTimelineModule.js +0 -321
- package/dist/js/Module.js +0 -478
- package/dist/js/PageAjaxModule.js +0 -1010
- package/dist/js/PageLoadMediaPlugin.js +0 -285
- package/dist/js/PageModule.js +0 -440
- package/dist/js/PaginationModule.js +0 -961
- package/dist/js/PaginationScrollPlugin.js +0 -209
- package/dist/js/Plugin.js +0 -114
- package/dist/js/PopupModule.js +0 -942
- package/dist/js/PreloaderModule.js +0 -724
- package/dist/js/ResponsiveProp.js +0 -301
- package/dist/js/ScrollAnchorModule.js +0 -554
- package/dist/js/ScrollAnimateModule.js +0 -419
- package/dist/js/ScrollBarPlugin.js +0 -594
- package/dist/js/ScrollDragPlugin.js +0 -396
- package/dist/js/ScrollModule.js +0 -1071
- package/dist/js/ScrollViewModule.js +0 -388
- package/dist/js/SelectModule.js +0 -860
- package/dist/js/SliderCanvasModule.js +0 -733
- package/dist/js/SliderControlsPlugin.js +0 -247
- package/dist/js/SliderCounterPlugin.js +0 -278
- package/dist/js/SliderDotsPlugin.js +0 -270
- package/dist/js/SliderDragSwipePlugin.js +0 -245
- package/dist/js/SliderIntervalPlugin.js +0 -192
- package/dist/js/SliderKeydownPlugin.js +0 -185
- package/dist/js/SliderModule.js +0 -1062
- package/dist/js/SliderWheelPlugin.js +0 -194
- package/dist/js/TextAnimateModule.js +0 -663
- package/dist/js/TextSplitModule.js +0 -785
- package/dist/js/TimelineBaseModule.js +0 -405
- package/dist/js/TimelineModule.js +0 -494
- package/dist/js/URLEvent.js +0 -239
- package/dist/js/ViewportEvent.js +0 -465
- package/dist/js/WheelEventModule.js +0 -295
- package/dist/js/domChildOf.js +0 -46
- package/dist/js/domChildren.js +0 -47
- package/dist/js/domInsertAfter.js +0 -32
- package/dist/js/domRemoveChildren.js +0 -26
- package/dist/js/easing.js +0 -363
- package/dist/js/eventListenerAdd.js +0 -87
- package/dist/js/eventListenerGet.js +0 -49
- package/dist/js/eventListenerRemove.js +0 -36
- package/dist/js/generateId.js +0 -29
- package/dist/js/getBrowserName.js +0 -60
- package/dist/js/getOsName.js +0 -39
- package/dist/js/getVevetProperties.js +0 -22
- package/dist/js/index.js +0 -519
- package/dist/js/mathScopeProgress.js +0 -32
- package/dist/js/mathSpreadScopeProgress.js +0 -35
- package/dist/js/merge.js +0 -33
- package/dist/js/normalizeWheel.js +0 -97
- package/dist/js/text_animate_module_addons/_composite_elementary.js +0 -196
- package/dist/js/text_animate_module_addons/_elementary.js +0 -88
- package/dist/js/timeoutCallback.js +0 -26
- package/dist/js/vevet.js +0 -10
- package/dist/scss/_prefix.scss +0 -1
- package/dist/scss/classes/_clear.scss +0 -5
- package/dist/scss/classes/_col-row.scss +0 -48
- package/dist/scss/classes/_display.scss +0 -65
- package/dist/scss/classes/_document-reset.scss +0 -28
- package/dist/scss/classes/_document.scss +0 -7
- package/dist/scss/classes/_overflow.scss +0 -39
- package/dist/scss/classes/_position.scss +0 -55
- package/dist/scss/classes/_text.scss +0 -24
- package/dist/scss/classes/_transition.scss +0 -22
- package/dist/scss/classes/_wrap.scss +0 -31
- package/dist/scss/classes/index.scss +0 -14
- package/dist/scss/index.scss +0 -3
- package/dist/scss/mixins/_clear.scss +0 -6
- package/dist/scss/mixins/_display.scss +0 -6
- package/dist/scss/mixins/_form.scss +0 -14
- package/dist/scss/mixins/_position.scss +0 -42
- package/dist/scss/mixins/_reset.scss +0 -17
- package/dist/scss/mixins/_responsive.scss +0 -88
- package/dist/scss/mixins/index.scss +0 -7
- package/dist/scss/modules/columns/_settings.scss +0 -1
- package/dist/scss/modules/columns/index.scss +0 -19
- package/dist/scss/modules/cursor/_settings.scss +0 -7
- package/dist/scss/modules/cursor/index.scss +0 -15
- package/dist/scss/modules/form/_settings.scss +0 -15
- package/dist/scss/modules/form/index.scss +0 -57
- package/dist/scss/modules/index.scss +0 -11
- package/dist/scss/modules/menu/_button.scss +0 -58
- package/dist/scss/modules/menu/_menu.scss +0 -25
- package/dist/scss/modules/menu/_settings.scss +0 -23
- package/dist/scss/modules/menu/index.scss +0 -3
- package/dist/scss/modules/pagination/_settings.scss +0 -6
- package/dist/scss/modules/pagination/index.scss +0 -24
- package/dist/scss/modules/popup/_settings.scss +0 -26
- package/dist/scss/modules/popup/index.scss +0 -294
- package/dist/scss/modules/preloader/_settings.scss +0 -3
- package/dist/scss/modules/preloader/index.scss +0 -19
- package/dist/scss/modules/scroll/_settings.scss +0 -22
- package/dist/scss/modules/scroll/index.scss +0 -94
- package/dist/scss/modules/select/_settings.scss +0 -28
- package/dist/scss/modules/select/index.scss +0 -142
- package/dist/scss/modules/slider/_settings.scss +0 -35
- package/dist/scss/modules/slider/index.scss +0 -153
- package/dist/scss/modules/text/_settings.scss +0 -1
- package/dist/scss/modules/text/index.scss +0 -19
- package/dist/types/types.d.ts +0 -18763
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.SmoothScroll = void 0;
|
|
33
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
34
|
+
var normalize_wheel_1 = __importDefault(require("normalize-wheel"));
|
|
35
|
+
var Component_1 = require("../../../base/Component");
|
|
36
|
+
var AnimationFrame_1 = require("../../animation-frame/AnimationFrame");
|
|
37
|
+
var boundVal_1 = __importDefault(require("../../../utils/math/boundVal"));
|
|
38
|
+
var math_1 = require("../../../utils/math");
|
|
39
|
+
/**
|
|
40
|
+
* Create smooth scrolling.
|
|
41
|
+
*/
|
|
42
|
+
var SmoothScroll = /** @class */ (function (_super) {
|
|
43
|
+
__extends(SmoothScroll, _super);
|
|
44
|
+
function SmoothScroll(initialProp, init) {
|
|
45
|
+
if (init === void 0) { init = true; }
|
|
46
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
47
|
+
var selectors = _this.prop.selectors;
|
|
48
|
+
// set default variables
|
|
49
|
+
_this._targetLeft = 0;
|
|
50
|
+
_this._targetTop = 0;
|
|
51
|
+
_this._scrollLeft = 0;
|
|
52
|
+
_this._scrollTop = 0;
|
|
53
|
+
_this._scrollWidth = 0;
|
|
54
|
+
_this._scrollHeight = 0;
|
|
55
|
+
_this._clientWidth = 0;
|
|
56
|
+
_this._clientHeight = 0;
|
|
57
|
+
_this._instant = false;
|
|
58
|
+
_this._currentFPS = 60;
|
|
59
|
+
// get outer elements
|
|
60
|
+
_this._outer = vevet_dom_1.selectOne(selectors.outer);
|
|
61
|
+
if (!(_this._outer instanceof HTMLElement)) {
|
|
62
|
+
throw new Error(selectors.outer + " is not a HTMLElement");
|
|
63
|
+
}
|
|
64
|
+
_this._outer.classList.add(_this.prefix);
|
|
65
|
+
// get or create container
|
|
66
|
+
var existingContainer = vevet_dom_1.selectOne("." + _this.prefix + "__container", _this.outer);
|
|
67
|
+
if (vevet_dom_1.isElement(existingContainer)) {
|
|
68
|
+
_this._container = existingContainer;
|
|
69
|
+
_this._containerExists = true;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
_this._container = vevet_dom_1.createElement('div', {
|
|
73
|
+
class: _this.prefix + "__container",
|
|
74
|
+
parent: _this.outer,
|
|
75
|
+
children: Array.from(_this.outer.children),
|
|
76
|
+
});
|
|
77
|
+
_this._containerExists = false;
|
|
78
|
+
}
|
|
79
|
+
// get scrollable elements
|
|
80
|
+
if (selectors.elements) {
|
|
81
|
+
_this._elements = Array.from(vevet_dom_1.selectAll(selectors.elements, _this._outer));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
_this._elements = [_this._container];
|
|
85
|
+
}
|
|
86
|
+
_this._elementsLength = _this._elements.length;
|
|
87
|
+
// add will-change
|
|
88
|
+
_this._elements.forEach(function (el) {
|
|
89
|
+
el.style.willChange = 'transform';
|
|
90
|
+
});
|
|
91
|
+
// initialize the class
|
|
92
|
+
if (init) {
|
|
93
|
+
_this.init();
|
|
94
|
+
}
|
|
95
|
+
return _this;
|
|
96
|
+
}
|
|
97
|
+
Object.defineProperty(SmoothScroll.prototype, "prefix", {
|
|
98
|
+
get: function () {
|
|
99
|
+
return this._app.prefix + "smooth-scroll";
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(SmoothScroll.prototype, "outer", {
|
|
105
|
+
get: function () {
|
|
106
|
+
return this._outer;
|
|
107
|
+
},
|
|
108
|
+
enumerable: false,
|
|
109
|
+
configurable: true
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(SmoothScroll.prototype, "container", {
|
|
112
|
+
get: function () {
|
|
113
|
+
return this._container;
|
|
114
|
+
},
|
|
115
|
+
enumerable: false,
|
|
116
|
+
configurable: true
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(SmoothScroll.prototype, "elements", {
|
|
119
|
+
get: function () {
|
|
120
|
+
return this._elements;
|
|
121
|
+
},
|
|
122
|
+
enumerable: false,
|
|
123
|
+
configurable: true
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(SmoothScroll.prototype, "targetLeft", {
|
|
126
|
+
get: function () {
|
|
127
|
+
return this._targetLeft;
|
|
128
|
+
},
|
|
129
|
+
set: function (val) {
|
|
130
|
+
this.targetLeftBound = val;
|
|
131
|
+
this._enable();
|
|
132
|
+
},
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(SmoothScroll.prototype, "targetLeftBound", {
|
|
137
|
+
get: function () {
|
|
138
|
+
return this._targetLeft;
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* Set value without animation request
|
|
142
|
+
*/
|
|
143
|
+
set: function (val) {
|
|
144
|
+
var min = !!this.prop.overscroll && this.prop.isHorizontal
|
|
145
|
+
? -this.prop.overscroll.max : 0;
|
|
146
|
+
var max = this.maxScrollableWidth
|
|
147
|
+
+ (!!this.prop.overscroll && this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
148
|
+
this._targetLeft = boundVal_1.default(val, [min, max]);
|
|
149
|
+
},
|
|
150
|
+
enumerable: false,
|
|
151
|
+
configurable: true
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(SmoothScroll.prototype, "targetTop", {
|
|
154
|
+
get: function () {
|
|
155
|
+
return this._targetTop;
|
|
156
|
+
},
|
|
157
|
+
set: function (val) {
|
|
158
|
+
this.targetTopBound = val;
|
|
159
|
+
this._enable();
|
|
160
|
+
},
|
|
161
|
+
enumerable: false,
|
|
162
|
+
configurable: true
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(SmoothScroll.prototype, "targetTopBound", {
|
|
165
|
+
get: function () {
|
|
166
|
+
return this._targetTop;
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* Set value without animation request
|
|
170
|
+
*/
|
|
171
|
+
set: function (val) {
|
|
172
|
+
var min = !!this.prop.overscroll && !this.prop.isHorizontal
|
|
173
|
+
? -this.prop.overscroll.max : 0;
|
|
174
|
+
var max = this.maxScrollableHeight
|
|
175
|
+
+ (!!this.prop.overscroll && !this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
176
|
+
this._targetTop = boundVal_1.default(val, [min, max]);
|
|
177
|
+
},
|
|
178
|
+
enumerable: false,
|
|
179
|
+
configurable: true
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(SmoothScroll.prototype, "scrollLeft", {
|
|
182
|
+
get: function () {
|
|
183
|
+
return this._scrollLeft;
|
|
184
|
+
},
|
|
185
|
+
set: function (val) {
|
|
186
|
+
this.targetLeftBound = val;
|
|
187
|
+
this._scrollLeft = this._targetLeft;
|
|
188
|
+
this._enable();
|
|
189
|
+
},
|
|
190
|
+
enumerable: false,
|
|
191
|
+
configurable: true
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(SmoothScroll.prototype, "scrollTop", {
|
|
194
|
+
get: function () {
|
|
195
|
+
return this._scrollTop;
|
|
196
|
+
},
|
|
197
|
+
set: function (val) {
|
|
198
|
+
this.targetTopBound = val;
|
|
199
|
+
this._scrollTop = this._targetTop;
|
|
200
|
+
this._enable();
|
|
201
|
+
},
|
|
202
|
+
enumerable: false,
|
|
203
|
+
configurable: true
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(SmoothScroll.prototype, "scrollWidth", {
|
|
206
|
+
get: function () {
|
|
207
|
+
return this._scrollWidth;
|
|
208
|
+
},
|
|
209
|
+
enumerable: false,
|
|
210
|
+
configurable: true
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(SmoothScroll.prototype, "scrollHeight", {
|
|
213
|
+
get: function () {
|
|
214
|
+
return this._scrollHeight;
|
|
215
|
+
},
|
|
216
|
+
enumerable: false,
|
|
217
|
+
configurable: true
|
|
218
|
+
});
|
|
219
|
+
Object.defineProperty(SmoothScroll.prototype, "clientWidth", {
|
|
220
|
+
get: function () {
|
|
221
|
+
return this._clientWidth;
|
|
222
|
+
},
|
|
223
|
+
enumerable: false,
|
|
224
|
+
configurable: true
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(SmoothScroll.prototype, "clientHeight", {
|
|
227
|
+
get: function () {
|
|
228
|
+
return this._clientHeight;
|
|
229
|
+
},
|
|
230
|
+
enumerable: false,
|
|
231
|
+
configurable: true
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(SmoothScroll.prototype, "maxScrollableWidth", {
|
|
234
|
+
/**
|
|
235
|
+
* Maximum scrollable area of the X axis
|
|
236
|
+
*/
|
|
237
|
+
get: function () {
|
|
238
|
+
return this.scrollWidth - this.clientWidth;
|
|
239
|
+
},
|
|
240
|
+
enumerable: false,
|
|
241
|
+
configurable: true
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(SmoothScroll.prototype, "maxScrollableHeight", {
|
|
244
|
+
/**
|
|
245
|
+
* Maximum scrollable area of the Y axis
|
|
246
|
+
*/
|
|
247
|
+
get: function () {
|
|
248
|
+
return this.scrollHeight - this.clientHeight;
|
|
249
|
+
},
|
|
250
|
+
enumerable: false,
|
|
251
|
+
configurable: true
|
|
252
|
+
});
|
|
253
|
+
SmoothScroll.prototype._getDefaultProp = function () {
|
|
254
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { selectors: {
|
|
255
|
+
outer: "#" + this.prefix,
|
|
256
|
+
elements: false,
|
|
257
|
+
}, enabled: true, animationFrame: false, recalculateSizes: true, useWheel: true, autoStop: true, isHorizontal: false, stopPropagation: true, useWillChange: true, render: {
|
|
258
|
+
lerp: 0.1,
|
|
259
|
+
lerpToFixed: 2,
|
|
260
|
+
approximation: 0.1,
|
|
261
|
+
normalizeLerp: false,
|
|
262
|
+
}, overscroll: {
|
|
263
|
+
friction: 0.5,
|
|
264
|
+
max: 250,
|
|
265
|
+
} });
|
|
266
|
+
};
|
|
267
|
+
// Extra constructor
|
|
268
|
+
SmoothScroll.prototype._constructor = function () {
|
|
269
|
+
_super.prototype._constructor.call(this);
|
|
270
|
+
this._toggle();
|
|
271
|
+
};
|
|
272
|
+
// Set Events
|
|
273
|
+
SmoothScroll.prototype._setEvents = function () {
|
|
274
|
+
var _this = this;
|
|
275
|
+
// update sizes
|
|
276
|
+
this.resize();
|
|
277
|
+
this.addViewportCallback('', function () {
|
|
278
|
+
_this.resize(true);
|
|
279
|
+
});
|
|
280
|
+
// wheel
|
|
281
|
+
this.addEventListeners(this.outer, 'wheel', function (e) {
|
|
282
|
+
_this._handleWheel(e);
|
|
283
|
+
});
|
|
284
|
+
// on scroll
|
|
285
|
+
this.addEventListeners(this.outer, 'scroll', function () {
|
|
286
|
+
_this.outer.scrollTop = 0;
|
|
287
|
+
_this.outer.scrollLeft = 0;
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
SmoothScroll.prototype._onPropMutate = function () {
|
|
291
|
+
_super.prototype._onPropMutate.call(this);
|
|
292
|
+
this.resize();
|
|
293
|
+
this._toggle();
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Recalculate scroll sizes
|
|
297
|
+
*/
|
|
298
|
+
SmoothScroll.prototype.resize = function (
|
|
299
|
+
/**
|
|
300
|
+
* If the method was called natively on window resize
|
|
301
|
+
*/
|
|
302
|
+
native) {
|
|
303
|
+
if (native === void 0) { native = false; }
|
|
304
|
+
// get elements
|
|
305
|
+
var _a = this, container = _a.container, outer = _a.outer;
|
|
306
|
+
// get sizes
|
|
307
|
+
this._clientWidth = outer.clientWidth;
|
|
308
|
+
this._clientHeight = outer.clientHeight;
|
|
309
|
+
this._scrollWidth = boundVal_1.default(container.clientWidth, [this.clientWidth, Infinity]);
|
|
310
|
+
this._scrollHeight = boundVal_1.default(container.clientHeight, [this.clientHeight, Infinity]);
|
|
311
|
+
// force instant change
|
|
312
|
+
// it means that after resizing, scrolling will be instantaneous for a while
|
|
313
|
+
if (native) {
|
|
314
|
+
this._instant = true;
|
|
315
|
+
}
|
|
316
|
+
// sometimes after resizing it may happen that targets are less or more
|
|
317
|
+
// than maximum values of scrolling
|
|
318
|
+
// that's why fix it here
|
|
319
|
+
if (native) {
|
|
320
|
+
this.targetLeft = parseInt(this.targetLeft.toFixed(0), 10);
|
|
321
|
+
this.targetTop = parseInt(this.targetTop.toFixed(0), 10);
|
|
322
|
+
}
|
|
323
|
+
// render elements
|
|
324
|
+
this._updateElementsProp();
|
|
325
|
+
// this.render();
|
|
326
|
+
// launch callbacks
|
|
327
|
+
this.callbacks.tbt('resize', false);
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Recalculate scroll sizes
|
|
331
|
+
*/
|
|
332
|
+
SmoothScroll.prototype._recalculateSizes = function () {
|
|
333
|
+
var container = this.container;
|
|
334
|
+
var height = container.clientHeight;
|
|
335
|
+
var width = container.clientWidth;
|
|
336
|
+
if ((height !== this.scrollHeight) || (width !== this.scrollWidth)) {
|
|
337
|
+
this.resize();
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Update elements' properties
|
|
342
|
+
*/
|
|
343
|
+
SmoothScroll.prototype._updateElementsProp = function () {
|
|
344
|
+
for (var index = 0; index < this._elementsLength; index += 1) {
|
|
345
|
+
var el = this._elements[index];
|
|
346
|
+
// update scroll values
|
|
347
|
+
el.smoothScrollLeft = this.scrollLeft;
|
|
348
|
+
el.smoothScrollTop = this.scrollTop;
|
|
349
|
+
// update easing
|
|
350
|
+
var easingAttr = el.getAttribute(this.prefix + "-ease");
|
|
351
|
+
if (easingAttr) {
|
|
352
|
+
try {
|
|
353
|
+
el.smoothScrollLerpEase = parseFloat(easingAttr);
|
|
354
|
+
}
|
|
355
|
+
catch (e) {
|
|
356
|
+
//
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* Event on wheel
|
|
363
|
+
*/
|
|
364
|
+
SmoothScroll.prototype._handleWheel = function (evt) {
|
|
365
|
+
var prop = this.prop;
|
|
366
|
+
if (!prop.enabled || !prop.useWheel) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
// stop propagation if needed
|
|
370
|
+
if (prop.stopPropagation
|
|
371
|
+
|| (!prop.stopPropagation
|
|
372
|
+
&& ((this.scrollLeft > 0
|
|
373
|
+
&& this.scrollLeft < this.maxScrollableWidth)
|
|
374
|
+
|| (this.scrollTop > 0
|
|
375
|
+
&& this.scrollTop < this.maxScrollableHeight)))) {
|
|
376
|
+
evt.stopImmediatePropagation();
|
|
377
|
+
evt.stopPropagation();
|
|
378
|
+
evt.preventDefault();
|
|
379
|
+
}
|
|
380
|
+
// get normalized delta
|
|
381
|
+
var delta = normalize_wheel_1.default(evt);
|
|
382
|
+
// set new scroll targets
|
|
383
|
+
this.targetLeftBound += prop.isHorizontal ? delta.pixelY : delta.pixelX;
|
|
384
|
+
this.targetTopBound += prop.isHorizontal ? delta.pixelX : delta.pixelY;
|
|
385
|
+
// play scroll
|
|
386
|
+
this._enable();
|
|
387
|
+
// launch events
|
|
388
|
+
this.callbacks.tbt('wheel', evt);
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Toggle animation: Enable / Disable scrolling
|
|
392
|
+
*/
|
|
393
|
+
SmoothScroll.prototype._toggle = function () {
|
|
394
|
+
if (this.prop.enabled) {
|
|
395
|
+
this._enable();
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
this._disable();
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Enable scrolling
|
|
403
|
+
*/
|
|
404
|
+
SmoothScroll.prototype._enable = function () {
|
|
405
|
+
var _this = this;
|
|
406
|
+
if (!this.prop.enabled) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
// set animation callback for the outer AnimationFrame
|
|
410
|
+
if (!!this.prop.animationFrame && !this._outerAnimationFrameEvent) {
|
|
411
|
+
this._outerAnimationFrameEvent = this.prop.animationFrame.addCallback('frame', function (data) {
|
|
412
|
+
_this._currentFPS = data.realFPS;
|
|
413
|
+
_this.render();
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
// otherwise, check if inner AnimationFrame is created
|
|
418
|
+
if (!this._animationFrame) {
|
|
419
|
+
this._animationFrame = new AnimationFrame_1.AnimationFrame();
|
|
420
|
+
this._animationFrame.addCallback('frame', function (data) {
|
|
421
|
+
_this._currentFPS = data.realFPS;
|
|
422
|
+
_this.render();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
this._animationFrame.play();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Disable scrolling
|
|
430
|
+
*/
|
|
431
|
+
SmoothScroll.prototype._disable = function () {
|
|
432
|
+
if (!!this._outerAnimationFrameEvent && !!this.prop.animationFrame) {
|
|
433
|
+
this._outerAnimationFrameEvent.remove();
|
|
434
|
+
}
|
|
435
|
+
if (this._animationFrame) {
|
|
436
|
+
this._animationFrame.pause();
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Render elements
|
|
441
|
+
*/
|
|
442
|
+
SmoothScroll.prototype.render = function () {
|
|
443
|
+
// vars
|
|
444
|
+
var prop = this.prop;
|
|
445
|
+
// recalculate sizes
|
|
446
|
+
if (prop.recalculateSizes) {
|
|
447
|
+
this._recalculateSizes();
|
|
448
|
+
}
|
|
449
|
+
// calculate scroll values
|
|
450
|
+
this._calcScroll();
|
|
451
|
+
// change elements' values
|
|
452
|
+
this._calcElements();
|
|
453
|
+
// render
|
|
454
|
+
this._renderElements();
|
|
455
|
+
// disable instant scrolling
|
|
456
|
+
if (this._instant) {
|
|
457
|
+
this._instant = false;
|
|
458
|
+
}
|
|
459
|
+
// launch events
|
|
460
|
+
this.callbacks.tbt('scroll', false);
|
|
461
|
+
// stop animation frame if values are approximated
|
|
462
|
+
var yDiff = Math.abs(this.targetTop - this.scrollTop);
|
|
463
|
+
var xDiff = Math.abs(this.targetLeft - this.scrollLeft);
|
|
464
|
+
if (xDiff === 0 && yDiff === 0 && prop.autoStop) {
|
|
465
|
+
this._disable();
|
|
466
|
+
this.callbacks.tbt('approximate', false);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Calculate scroll value
|
|
471
|
+
*/
|
|
472
|
+
SmoothScroll.prototype._calcScroll = function () {
|
|
473
|
+
var overscroll = this.prop.overscroll;
|
|
474
|
+
// use overscroll
|
|
475
|
+
if (overscroll) {
|
|
476
|
+
// left
|
|
477
|
+
if (this.targetLeft < 0) {
|
|
478
|
+
this.targetLeftBound = this._lerp(this.targetLeftBound, 0, overscroll.friction);
|
|
479
|
+
}
|
|
480
|
+
else if (this.targetLeft > this.maxScrollableWidth) {
|
|
481
|
+
this.targetLeftBound = this._lerp(this.targetLeftBound, this.maxScrollableWidth, overscroll.friction);
|
|
482
|
+
}
|
|
483
|
+
// top
|
|
484
|
+
if (this.targetTop < 0) {
|
|
485
|
+
this.targetTopBound = this._lerp(this.targetTopBound, 0, overscroll.friction);
|
|
486
|
+
}
|
|
487
|
+
else if (this.targetTop > this.maxScrollableHeight) {
|
|
488
|
+
this.targetTopBound = this._lerp(this.targetTopBound, this.maxScrollableHeight, overscroll.friction);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
// update values
|
|
492
|
+
this._scrollLeft = this._lerp(this.scrollLeft, this.targetLeft);
|
|
493
|
+
this._scrollTop = this._lerp(this.scrollTop, this.targetTop);
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* Calculate elements' values.
|
|
497
|
+
*/
|
|
498
|
+
SmoothScroll.prototype._calcElements = function () {
|
|
499
|
+
var globalEase = this._getLerpEase();
|
|
500
|
+
for (var index = 0; index < this._elementsLength; index += 1) {
|
|
501
|
+
var el = this._elements[index];
|
|
502
|
+
// get element ease
|
|
503
|
+
var elEase = this._getLerpEase(el);
|
|
504
|
+
// change values
|
|
505
|
+
if (elEase === globalEase) {
|
|
506
|
+
el.smoothScrollLeft = this._scrollLeft;
|
|
507
|
+
el.smoothScrollTop = this._scrollTop;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
el.smoothScrollLeft = this._lerp(el.smoothScrollLeft, this._targetLeft, elEase);
|
|
511
|
+
el.smoothScrollTop = this._lerp(el.smoothScrollTop, this._targetTop, elEase);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* Interpolate values
|
|
517
|
+
*/
|
|
518
|
+
SmoothScroll.prototype._lerp = function (current, target, ease) {
|
|
519
|
+
if (ease === void 0) { ease = this._getLerpEase(); }
|
|
520
|
+
var _a = this.prop.render, lerpToFixed = _a.lerpToFixed, approximation = _a.approximation;
|
|
521
|
+
var currentEase = this._instant ? 1 : ease;
|
|
522
|
+
var val = math_1.lerp(current, target, currentEase, approximation);
|
|
523
|
+
// round the values
|
|
524
|
+
if (typeof lerpToFixed === 'number') {
|
|
525
|
+
var fixed = Math.round(Math.abs(lerpToFixed));
|
|
526
|
+
return parseFloat(val.toFixed(fixed));
|
|
527
|
+
}
|
|
528
|
+
return val;
|
|
529
|
+
};
|
|
530
|
+
/**
|
|
531
|
+
* Get element ease
|
|
532
|
+
*/
|
|
533
|
+
SmoothScroll.prototype._getLerpEase = function (el) {
|
|
534
|
+
if (el === void 0) { el = false; }
|
|
535
|
+
var _a = this.prop.render, lerpEase = _a.lerp, normalizeLerp = _a.normalizeLerp;
|
|
536
|
+
var fpsMultiplier = normalizeLerp ? 60 / this._currentFPS : 1;
|
|
537
|
+
if (el) {
|
|
538
|
+
return el.smoothScrollLerpEase || lerpEase * fpsMultiplier;
|
|
539
|
+
}
|
|
540
|
+
return lerpEase * fpsMultiplier;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Render elements
|
|
544
|
+
*/
|
|
545
|
+
SmoothScroll.prototype._renderElements = function () {
|
|
546
|
+
for (var index = 0; index < this._elementsLength; index += 1) {
|
|
547
|
+
var el = this._elements[index];
|
|
548
|
+
// coords
|
|
549
|
+
var x = -el.smoothScrollLeft;
|
|
550
|
+
var y = -el.smoothScrollTop;
|
|
551
|
+
// set styles
|
|
552
|
+
el.style.transform = "matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, " + x + ", " + y + ", 0,1)";
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
// LIKE NATIVE SCROLL
|
|
556
|
+
/**
|
|
557
|
+
* Scroll to
|
|
558
|
+
*/
|
|
559
|
+
SmoothScroll.prototype.scrollTo = function () {
|
|
560
|
+
// eslint-disable-next-line prefer-rest-params
|
|
561
|
+
var arg = arguments;
|
|
562
|
+
// if object
|
|
563
|
+
if (arg.length === 1 && typeof arg[0] === 'object') {
|
|
564
|
+
var options = arg[0];
|
|
565
|
+
var top_1 = options.top, left = options.left, behavior = options.behavior;
|
|
566
|
+
if (typeof left !== 'undefined') {
|
|
567
|
+
if (behavior === 'smooth') {
|
|
568
|
+
this.targetLeftBound = left;
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
this.scrollLeft = left;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (typeof top_1 !== 'undefined') {
|
|
575
|
+
if (behavior === 'smooth') {
|
|
576
|
+
this.targetTopBound = top_1;
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
this.scrollTop = top_1;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (behavior === 'smooth') {
|
|
583
|
+
this._enable();
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
// if numbers
|
|
587
|
+
if (typeof arg[0] === 'number' || typeof arg[1] === 'number') {
|
|
588
|
+
if (typeof arg[0] === 'number') {
|
|
589
|
+
// eslint-disable-next-line prefer-destructuring
|
|
590
|
+
this.scrollLeft = arg[0];
|
|
591
|
+
}
|
|
592
|
+
if (typeof arg[1] === 'number') {
|
|
593
|
+
// eslint-disable-next-line prefer-destructuring
|
|
594
|
+
this.scrollTop = arg[1];
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Destroy the scroll
|
|
600
|
+
*/
|
|
601
|
+
SmoothScroll.prototype._destroy = function () {
|
|
602
|
+
_super.prototype._destroy.call(this);
|
|
603
|
+
// disable animation
|
|
604
|
+
this._disable();
|
|
605
|
+
if (this._animationFrame) {
|
|
606
|
+
this._animationFrame.destroy();
|
|
607
|
+
}
|
|
608
|
+
// destroy container
|
|
609
|
+
if (!this._containerExists) {
|
|
610
|
+
while (this._container.firstChild) {
|
|
611
|
+
this._outer.appendChild(this._container.firstChild);
|
|
612
|
+
}
|
|
613
|
+
this._container.remove();
|
|
614
|
+
}
|
|
615
|
+
// remove classes
|
|
616
|
+
this._outer.classList.remove(this.prefix);
|
|
617
|
+
// reset styles
|
|
618
|
+
this._elements.forEach(function (el) {
|
|
619
|
+
el.style.transform = '';
|
|
620
|
+
el.style.willChange = '';
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
return SmoothScroll;
|
|
624
|
+
}(Component_1.Component));
|
|
625
|
+
exports.SmoothScroll = SmoothScroll;
|