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,84 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DraggerMove = void 0;
|
|
19
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
20
|
+
var Dragger_1 = require("./Dragger");
|
|
21
|
+
/**
|
|
22
|
+
* Dragger with 'move' callbacks and motion.
|
|
23
|
+
*/
|
|
24
|
+
var DraggerMove = /** @class */ (function (_super) {
|
|
25
|
+
__extends(DraggerMove, _super);
|
|
26
|
+
function DraggerMove() {
|
|
27
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(DraggerMove.prototype, "stepCoords", {
|
|
30
|
+
/**
|
|
31
|
+
* Step on move
|
|
32
|
+
*/
|
|
33
|
+
get: function () {
|
|
34
|
+
return {
|
|
35
|
+
x: this._coords.x - this._prevCoords.x,
|
|
36
|
+
y: this._coords.y - this._prevCoords.y,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Add runtime events
|
|
44
|
+
*/
|
|
45
|
+
DraggerMove.prototype._addRuntimeEvents = function () {
|
|
46
|
+
_super.prototype._addRuntimeEvents.call(this);
|
|
47
|
+
var usePassive = this.prop.usePassive;
|
|
48
|
+
// move
|
|
49
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'mousemove', this._handleMove.bind(this), {
|
|
50
|
+
passive: usePassive,
|
|
51
|
+
}));
|
|
52
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'touchmove', this._handleMove.bind(this), {
|
|
53
|
+
passive: usePassive,
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Event on move
|
|
58
|
+
*/
|
|
59
|
+
DraggerMove.prototype._handleMove = function (e) {
|
|
60
|
+
var evt = this._normalizeEvent(e);
|
|
61
|
+
if (!this.isDragging || evt.id !== this._pointerID) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// update coordinates
|
|
65
|
+
this._prevCoords = { x: this._coords.x, y: this._coords.y };
|
|
66
|
+
this._coords = { x: evt.x, y: evt.y };
|
|
67
|
+
// call events
|
|
68
|
+
this.callbacks.tbt('move', {
|
|
69
|
+
evt: e,
|
|
70
|
+
start: this.startCoords,
|
|
71
|
+
coords: this.coords,
|
|
72
|
+
step: this.stepCoords,
|
|
73
|
+
});
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Destroy the module
|
|
78
|
+
*/
|
|
79
|
+
DraggerMove.prototype._destroy = function () {
|
|
80
|
+
_super.prototype._destroy.call(this);
|
|
81
|
+
};
|
|
82
|
+
return DraggerMove;
|
|
83
|
+
}(Dragger_1.Dragger));
|
|
84
|
+
exports.DraggerMove = DraggerMove;
|
|
@@ -0,0 +1,229 @@
|
|
|
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.Preloader = void 0;
|
|
33
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
34
|
+
var p_cancelable_1 = __importDefault(require("p-cancelable"));
|
|
35
|
+
var Component_1 = require("../../base/Component");
|
|
36
|
+
var timeoutCallback_1 = __importDefault(require("../../utils/common/timeoutCallback"));
|
|
37
|
+
/**
|
|
38
|
+
* A page preloader
|
|
39
|
+
*/
|
|
40
|
+
var Preloader = /** @class */ (function (_super) {
|
|
41
|
+
__extends(Preloader, _super);
|
|
42
|
+
function Preloader(initialProp, init) {
|
|
43
|
+
if (init === void 0) { init = true; }
|
|
44
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
45
|
+
// get preloader container
|
|
46
|
+
if (_this.prop.container) {
|
|
47
|
+
var container = vevet_dom_1.selectOne(_this.prop.container);
|
|
48
|
+
if (container instanceof HTMLElement) {
|
|
49
|
+
_this._container = container;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// add classes
|
|
53
|
+
if (_this._container) {
|
|
54
|
+
_this._container.classList.add(_this.prefix);
|
|
55
|
+
}
|
|
56
|
+
// set default vars
|
|
57
|
+
_this._startTime = +new Date();
|
|
58
|
+
_this._endTime = Infinity;
|
|
59
|
+
_this._toBeHidden = false;
|
|
60
|
+
_this._isHidden = false;
|
|
61
|
+
// initialize the class
|
|
62
|
+
if (init) {
|
|
63
|
+
_this.init();
|
|
64
|
+
}
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
Preloader.prototype._getDefaultProp = function () {
|
|
68
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#" + this.prefix, hide: 250 });
|
|
69
|
+
};
|
|
70
|
+
Object.defineProperty(Preloader.prototype, "prefix", {
|
|
71
|
+
get: function () {
|
|
72
|
+
return this._app.prefix + "preloader";
|
|
73
|
+
},
|
|
74
|
+
enumerable: false,
|
|
75
|
+
configurable: true
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(Preloader.prototype, "container", {
|
|
78
|
+
/**
|
|
79
|
+
* Preloader container
|
|
80
|
+
*/
|
|
81
|
+
get: function () {
|
|
82
|
+
return this._container;
|
|
83
|
+
},
|
|
84
|
+
enumerable: false,
|
|
85
|
+
configurable: true
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(Preloader.prototype, "startTime", {
|
|
88
|
+
/**
|
|
89
|
+
* Preloader start time
|
|
90
|
+
*/
|
|
91
|
+
get: function () {
|
|
92
|
+
return this._startTime;
|
|
93
|
+
},
|
|
94
|
+
enumerable: false,
|
|
95
|
+
configurable: true
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(Preloader.prototype, "endTime", {
|
|
98
|
+
/**
|
|
99
|
+
* Preloader end time
|
|
100
|
+
*/
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._endTime;
|
|
103
|
+
},
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(Preloader.prototype, "totalTime", {
|
|
108
|
+
/**
|
|
109
|
+
* Total time of page loading before the preloader is to be hidden
|
|
110
|
+
*/
|
|
111
|
+
get: function () {
|
|
112
|
+
return this._endTime - this._startTime;
|
|
113
|
+
},
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(Preloader.prototype, "isHidden", {
|
|
118
|
+
/**
|
|
119
|
+
* If the preloader is hidden
|
|
120
|
+
*/
|
|
121
|
+
get: function () {
|
|
122
|
+
return this._isHidden;
|
|
123
|
+
},
|
|
124
|
+
enumerable: false,
|
|
125
|
+
configurable: true
|
|
126
|
+
});
|
|
127
|
+
Preloader.prototype._setEvents = function () {
|
|
128
|
+
var _this = this;
|
|
129
|
+
_super.prototype._setEvents.call(this);
|
|
130
|
+
this._onLoaded().then(function () {
|
|
131
|
+
_this._endTime = +new Date();
|
|
132
|
+
_this._handleLoaded();
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Trace the moment when the page is fully loaded
|
|
137
|
+
*/
|
|
138
|
+
Preloader.prototype._onLoaded = function () {
|
|
139
|
+
var _this = this;
|
|
140
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
141
|
+
if (_this._app.pageLoad.loaded) {
|
|
142
|
+
resolve();
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
_this._pageLoadEvent = _this._app.pageLoad.add('', function () {
|
|
146
|
+
resolve();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* When the page is fully loaded
|
|
153
|
+
*/
|
|
154
|
+
Preloader.prototype._handleLoaded = function () {
|
|
155
|
+
this.callbacks.tbt('loaded', false);
|
|
156
|
+
// hide the preloader
|
|
157
|
+
if (typeof this.prop.hide !== 'boolean') {
|
|
158
|
+
this.hideContainer();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Hide the container
|
|
163
|
+
*/
|
|
164
|
+
Preloader.prototype.hideContainer = function (duration) {
|
|
165
|
+
var _this = this;
|
|
166
|
+
if (duration === void 0) { duration = typeof this.prop.hide !== 'boolean' ? this.prop.hide : 250; }
|
|
167
|
+
this.callbacks.tbt('hide', false);
|
|
168
|
+
this._toBeHidden = true;
|
|
169
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
170
|
+
var container = _this._container;
|
|
171
|
+
// if container is not to be hidden
|
|
172
|
+
if (!container) {
|
|
173
|
+
_this._handleHidden();
|
|
174
|
+
resolve();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// if need to hide the container
|
|
178
|
+
container.style.transition = "opacity " + duration + "ms, visibility " + duration + "ms";
|
|
179
|
+
container.style.opacity = '0';
|
|
180
|
+
container.style.visibility = 'hidden';
|
|
181
|
+
timeoutCallback_1.default(function () {
|
|
182
|
+
container.style.display = 'none';
|
|
183
|
+
_this._handleHidden();
|
|
184
|
+
resolve();
|
|
185
|
+
}, duration);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Handle the moment when the container is hidden
|
|
190
|
+
*/
|
|
191
|
+
Preloader.prototype._handleHidden = function () {
|
|
192
|
+
this._isHidden = true;
|
|
193
|
+
this.callbacks.tbt('hidden', false);
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Callback at the moment when the preloader starts hiding
|
|
197
|
+
*/
|
|
198
|
+
Preloader.prototype.onHide = function (callback) {
|
|
199
|
+
if (this._toBeHidden) {
|
|
200
|
+
callback();
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
return this.callbacks.add('hide', function () {
|
|
204
|
+
callback();
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Callback at the moment when the preloader is hidden
|
|
209
|
+
*/
|
|
210
|
+
Preloader.prototype.onHidden = function (callback) {
|
|
211
|
+
if (this._isHidden) {
|
|
212
|
+
callback();
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
return this.callbacks.add('hidden', function () {
|
|
216
|
+
callback();
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Destroy the module
|
|
221
|
+
*/
|
|
222
|
+
Preloader.prototype._destroy = function () {
|
|
223
|
+
var _a;
|
|
224
|
+
_super.prototype._destroy.call(this);
|
|
225
|
+
(_a = this._pageLoadEvent) === null || _a === void 0 ? void 0 : _a.remove();
|
|
226
|
+
};
|
|
227
|
+
return Preloader;
|
|
228
|
+
}(Component_1.Component));
|
|
229
|
+
exports.Preloader = Preloader;
|
|
@@ -0,0 +1,377 @@
|
|
|
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.ProgressPreloader = void 0;
|
|
33
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
34
|
+
var p_cancelable_1 = __importDefault(require("p-cancelable"));
|
|
35
|
+
var AnimationFrame_1 = require("../animation-frame/AnimationFrame");
|
|
36
|
+
var lerp_1 = __importDefault(require("../../utils/math/lerp"));
|
|
37
|
+
var Preloader_1 = require("./Preloader");
|
|
38
|
+
var Timeline_1 = require("../timeline/Timeline");
|
|
39
|
+
/**
|
|
40
|
+
* A page preloader with smooth progress calculation
|
|
41
|
+
*/
|
|
42
|
+
var ProgressPreloader = /** @class */ (function (_super) {
|
|
43
|
+
__extends(ProgressPreloader, _super);
|
|
44
|
+
function ProgressPreloader(initialProp, init) {
|
|
45
|
+
if (init === void 0) { init = true; }
|
|
46
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
47
|
+
// set default vars
|
|
48
|
+
_this._imgs = [];
|
|
49
|
+
_this._videos = [];
|
|
50
|
+
_this._customResources = [];
|
|
51
|
+
_this._resourcesTotal = 1 + _this.prop.resources;
|
|
52
|
+
_this._resourcesLoaded = 0;
|
|
53
|
+
_this._progress = 0;
|
|
54
|
+
// initialize the class
|
|
55
|
+
if (init) {
|
|
56
|
+
_this.init();
|
|
57
|
+
}
|
|
58
|
+
return _this;
|
|
59
|
+
}
|
|
60
|
+
ProgressPreloader.prototype._getDefaultProp = function () {
|
|
61
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { resources: 0, loaders: {
|
|
62
|
+
img: true,
|
|
63
|
+
video: true,
|
|
64
|
+
custom: '.js-preload',
|
|
65
|
+
}, calc: {
|
|
66
|
+
lerp: 0.1,
|
|
67
|
+
forceEnd: 500,
|
|
68
|
+
} });
|
|
69
|
+
};
|
|
70
|
+
Object.defineProperty(ProgressPreloader.prototype, "imgs", {
|
|
71
|
+
/**
|
|
72
|
+
* Image resources
|
|
73
|
+
*/
|
|
74
|
+
get: function () {
|
|
75
|
+
return this._imgs;
|
|
76
|
+
},
|
|
77
|
+
enumerable: false,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(ProgressPreloader.prototype, "videos", {
|
|
81
|
+
/**
|
|
82
|
+
* Video resources
|
|
83
|
+
*/
|
|
84
|
+
get: function () {
|
|
85
|
+
return this._videos;
|
|
86
|
+
},
|
|
87
|
+
enumerable: false,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(ProgressPreloader.prototype, "customResources", {
|
|
91
|
+
/**
|
|
92
|
+
* Custom resources
|
|
93
|
+
*/
|
|
94
|
+
get: function () {
|
|
95
|
+
return this._customResources;
|
|
96
|
+
},
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(ProgressPreloader.prototype, "resourcesTotal", {
|
|
101
|
+
/**
|
|
102
|
+
* Quantity of resources to be preloader
|
|
103
|
+
*/
|
|
104
|
+
get: function () {
|
|
105
|
+
return this._resourcesTotal;
|
|
106
|
+
},
|
|
107
|
+
enumerable: false,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(ProgressPreloader.prototype, "resourcesLoaded", {
|
|
111
|
+
/**
|
|
112
|
+
* Quantity of resources been already loaded
|
|
113
|
+
*/
|
|
114
|
+
get: function () {
|
|
115
|
+
return this._resourcesLoaded;
|
|
116
|
+
},
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(ProgressPreloader.prototype, "loadProgress", {
|
|
121
|
+
/**
|
|
122
|
+
* Progress of resources loaded
|
|
123
|
+
*/
|
|
124
|
+
get: function () {
|
|
125
|
+
return this.resourcesLoaded / this.resourcesTotal;
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(ProgressPreloader.prototype, "progress", {
|
|
131
|
+
/**
|
|
132
|
+
* Preloader progress
|
|
133
|
+
*/
|
|
134
|
+
get: function () {
|
|
135
|
+
return this._progress;
|
|
136
|
+
},
|
|
137
|
+
set: function (val) {
|
|
138
|
+
this._progress = val;
|
|
139
|
+
this._handleProgress();
|
|
140
|
+
},
|
|
141
|
+
enumerable: false,
|
|
142
|
+
configurable: true
|
|
143
|
+
});
|
|
144
|
+
ProgressPreloader.prototype._constructor = function () {
|
|
145
|
+
_super.prototype._constructor.call(this);
|
|
146
|
+
this._getResources();
|
|
147
|
+
};
|
|
148
|
+
ProgressPreloader.prototype._setEvents = function () {
|
|
149
|
+
var _this = this;
|
|
150
|
+
_super.prototype._setEvents.call(this);
|
|
151
|
+
var calc = this.prop.calc;
|
|
152
|
+
var lerpVal = calc.lerp;
|
|
153
|
+
// create animation frame if needed
|
|
154
|
+
if (typeof lerpVal === 'number') {
|
|
155
|
+
this._animationFrame = new AnimationFrame_1.AnimationFrame();
|
|
156
|
+
this._animationFrame.addCallback('frame', function () {
|
|
157
|
+
_this.progress = lerp_1.default(_this.progress, _this.loadProgress, lerpVal);
|
|
158
|
+
});
|
|
159
|
+
this._animationFrame.play();
|
|
160
|
+
}
|
|
161
|
+
// preload resources
|
|
162
|
+
this._preloadResources();
|
|
163
|
+
// iterate resources on page load
|
|
164
|
+
this._app.onPageLoaded().then(function () {
|
|
165
|
+
_this._handleLoadedResource();
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Seek the moment when the page is fully loaded
|
|
170
|
+
*/
|
|
171
|
+
ProgressPreloader.prototype._onLoaded = function () {
|
|
172
|
+
var _this = this;
|
|
173
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
174
|
+
var callbackLaunched = false;
|
|
175
|
+
_this.callbacks.add('progress', function (data) {
|
|
176
|
+
if (data.progress >= 1 && !callbackLaunched) {
|
|
177
|
+
resolve();
|
|
178
|
+
callbackLaunched = true;
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
protected: true,
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Get resources to be preloader
|
|
187
|
+
*/
|
|
188
|
+
ProgressPreloader.prototype._getResources = function () {
|
|
189
|
+
var _this = this;
|
|
190
|
+
var loaders = this.prop.loaders;
|
|
191
|
+
// get images
|
|
192
|
+
if (loaders.img) {
|
|
193
|
+
var imgs = vevet_dom_1.selectAll('img');
|
|
194
|
+
imgs.forEach(function (img) {
|
|
195
|
+
_this._imgs.push(img);
|
|
196
|
+
_this._resourcesTotal += 1;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// get videos
|
|
200
|
+
if (loaders.video) {
|
|
201
|
+
var videos = vevet_dom_1.selectAll('video');
|
|
202
|
+
videos.forEach(function (video) {
|
|
203
|
+
_this._videos.push(video);
|
|
204
|
+
_this._resourcesTotal += 1;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// get custom resources
|
|
208
|
+
if (loaders.custom) {
|
|
209
|
+
this._customResources = Array.from(vevet_dom_1.selectAll(loaders.custom));
|
|
210
|
+
this._resourcesTotal += this._customResources.length;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Preload all resources
|
|
215
|
+
*/
|
|
216
|
+
ProgressPreloader.prototype._preloadResources = function () {
|
|
217
|
+
var _this = this;
|
|
218
|
+
// check if no resources
|
|
219
|
+
if (this._resourcesTotal === 0) {
|
|
220
|
+
this._resourcesTotal = 1;
|
|
221
|
+
this._handleLoadedResource();
|
|
222
|
+
}
|
|
223
|
+
// preload images
|
|
224
|
+
this._imgs.forEach(function (img) {
|
|
225
|
+
if (img.complete) {
|
|
226
|
+
_this._handleLoadedResource();
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
var image = new Image();
|
|
230
|
+
img.addEventListener('load', function () {
|
|
231
|
+
_this._handleLoadedResource();
|
|
232
|
+
});
|
|
233
|
+
img.addEventListener('error', function () {
|
|
234
|
+
_this._handleLoadedResource();
|
|
235
|
+
});
|
|
236
|
+
image.src = img.src;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
// preload videos
|
|
240
|
+
this._videos.forEach(function (video) {
|
|
241
|
+
if (video.readyState > 0) {
|
|
242
|
+
_this._handleLoadedResource();
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
if (video.preload === 'none') {
|
|
246
|
+
_this._handleLoadedResource();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
video.addEventListener('error', function () {
|
|
250
|
+
_this._handleLoadedResource();
|
|
251
|
+
});
|
|
252
|
+
video.addEventListener('loadedmetadata', function () {
|
|
253
|
+
_this._handleLoadedResource();
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// preload custom resources
|
|
258
|
+
this._customResources.forEach(function (el) {
|
|
259
|
+
_this._seekCustomResourceLoaded(el).then(function () {
|
|
260
|
+
_this._handleLoadedResource();
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Seek the moment when a custom resource is loaded
|
|
266
|
+
*/
|
|
267
|
+
ProgressPreloader.prototype._seekCustomResourceLoaded = function (el) {
|
|
268
|
+
var _this = this;
|
|
269
|
+
return new Promise(function (resolve) {
|
|
270
|
+
// check if the element is loaded
|
|
271
|
+
if (el.isComplete || el.isLoaded) {
|
|
272
|
+
resolve();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (el.getAttribute('data-is-loaded')
|
|
276
|
+
|| el.getAttribute('is-loaded')) {
|
|
277
|
+
resolve();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// otherwise, seek the moment when it will be loaded
|
|
281
|
+
setTimeout(function () {
|
|
282
|
+
if (_this.destroyed) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
_this._seekCustomResourceLoaded(el).then(function () {
|
|
286
|
+
resolve();
|
|
287
|
+
});
|
|
288
|
+
}, 50);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Iterate quantity of loaded resources.
|
|
293
|
+
* @param quantity - Only integers
|
|
294
|
+
*/
|
|
295
|
+
ProgressPreloader.prototype.addResourcesLoaded = function (quantity) {
|
|
296
|
+
if (quantity === void 0) { quantity = 1; }
|
|
297
|
+
for (var index = 0; index < quantity; index += 1) {
|
|
298
|
+
this._handleLoadedResource();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Iterate quantity of total resources.
|
|
303
|
+
* @param quantity - Only integers
|
|
304
|
+
*/
|
|
305
|
+
ProgressPreloader.prototype.addResourcesTotal = function (quantity) {
|
|
306
|
+
if (quantity === void 0) { quantity = 1; }
|
|
307
|
+
this._resourcesTotal += quantity;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Event on resource loaded
|
|
311
|
+
*/
|
|
312
|
+
ProgressPreloader.prototype._handleLoadedResource = function () {
|
|
313
|
+
if (this.loadProgress >= 1) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this._resourcesLoaded += 1;
|
|
317
|
+
this.callbacks.tbt('resourceLoad', false);
|
|
318
|
+
// update current preloader progress if no animation set
|
|
319
|
+
if (!this._animationFrame) {
|
|
320
|
+
this.progress = this.loadProgress;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Event on progress change
|
|
325
|
+
*/
|
|
326
|
+
ProgressPreloader.prototype._handleProgress = function () {
|
|
327
|
+
var _this = this;
|
|
328
|
+
// launch callback
|
|
329
|
+
this.callbacks.tbt('progress', {
|
|
330
|
+
progress: this._progress,
|
|
331
|
+
});
|
|
332
|
+
// if full progress,
|
|
333
|
+
// we hide the preloader
|
|
334
|
+
if (this.progress >= 1) {
|
|
335
|
+
// destroy animations
|
|
336
|
+
if (this._animationFrame) {
|
|
337
|
+
this._animationFrame.destroy();
|
|
338
|
+
this._animationFrame = undefined;
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
// otherwise, we check if there's a need to launch a timeline
|
|
343
|
+
// to end the animation
|
|
344
|
+
if (typeof this.prop.calc.forceEnd === 'number'
|
|
345
|
+
&& this.loadProgress >= 1
|
|
346
|
+
&& !this._endTimeline) {
|
|
347
|
+
// destroy animation frame
|
|
348
|
+
if (this._animationFrame) {
|
|
349
|
+
this._animationFrame.destroy();
|
|
350
|
+
this._animationFrame = undefined;
|
|
351
|
+
}
|
|
352
|
+
// create a timeline
|
|
353
|
+
this._endTimeline = new Timeline_1.Timeline({
|
|
354
|
+
duration: this.prop.calc.forceEnd,
|
|
355
|
+
});
|
|
356
|
+
var startProgress_1 = this.progress;
|
|
357
|
+
this._endTimeline.addCallback('progress', function (data) {
|
|
358
|
+
var diff = 1 - startProgress_1;
|
|
359
|
+
_this.progress = startProgress_1 + (diff * data.progress);
|
|
360
|
+
});
|
|
361
|
+
this._endTimeline.play();
|
|
362
|
+
}
|
|
363
|
+
// and since some time the preloader will be hidden automatically.
|
|
364
|
+
// See '_onLoaded' method.
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Destroy the component
|
|
368
|
+
*/
|
|
369
|
+
ProgressPreloader.prototype._destroy = function () {
|
|
370
|
+
_super.prototype._destroy.call(this);
|
|
371
|
+
if (this._animationFrame) {
|
|
372
|
+
this._animationFrame.destroy();
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return ProgressPreloader;
|
|
376
|
+
}(Preloader_1.Preloader));
|
|
377
|
+
exports.ProgressPreloader = ProgressPreloader;
|