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,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Application = void 0;
|
|
18
|
+
var ismobilejs_1 = __importDefault(require("ismobilejs"));
|
|
19
|
+
var detect_browser_1 = require("detect-browser");
|
|
20
|
+
var p_cancelable_1 = __importDefault(require("p-cancelable"));
|
|
21
|
+
var Viewport_1 = require("./events/Viewport");
|
|
22
|
+
var PageLoad_1 = require("./events/PageLoad");
|
|
23
|
+
/**
|
|
24
|
+
* Vevet Application
|
|
25
|
+
*/
|
|
26
|
+
var Application = /** @class */ (function () {
|
|
27
|
+
/**
|
|
28
|
+
* @example
|
|
29
|
+
* const app = Application({
|
|
30
|
+
* page: 'home'
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
function Application(data) {
|
|
34
|
+
if (data === void 0) { data = {}; }
|
|
35
|
+
/**
|
|
36
|
+
* Pages (instances)
|
|
37
|
+
*/
|
|
38
|
+
this._pages = [];
|
|
39
|
+
/**
|
|
40
|
+
* Current Page (instance).
|
|
41
|
+
*/
|
|
42
|
+
this._page = false;
|
|
43
|
+
// check if the application already exists
|
|
44
|
+
if (window.vevetApp) {
|
|
45
|
+
throw new Error('Vevet Application already exists!');
|
|
46
|
+
}
|
|
47
|
+
// set defaults
|
|
48
|
+
this._prop = __assign(__assign({}, this.defaultProp), data);
|
|
49
|
+
this._prefix = this.prop.prefix;
|
|
50
|
+
// initialize the application
|
|
51
|
+
// Define that you're using Vevet
|
|
52
|
+
this._sayHi();
|
|
53
|
+
// add the application to the window
|
|
54
|
+
window.vevetApp = this;
|
|
55
|
+
// get type of device
|
|
56
|
+
var ifmobile = ismobilejs_1.default();
|
|
57
|
+
this._isPhone = ifmobile.phone;
|
|
58
|
+
this.html.classList.toggle(this.prefix + "phone", this._isPhone);
|
|
59
|
+
this._isTablet = ifmobile.tablet;
|
|
60
|
+
this.html.classList.toggle(this.prefix + "tablet", this._isTablet);
|
|
61
|
+
this._isMobile = ifmobile.phone || ifmobile.tablet;
|
|
62
|
+
this.html.classList.toggle(this.prefix + "mobile", this._isMobile);
|
|
63
|
+
this._isDesktop = !this._isMobile;
|
|
64
|
+
this.html.classList.toggle(this.prefix + "desktop", this._isDesktop);
|
|
65
|
+
// get browser info
|
|
66
|
+
var browserData = detect_browser_1.detect();
|
|
67
|
+
// get OS name
|
|
68
|
+
if (browserData === null || browserData === void 0 ? void 0 : browserData.os) {
|
|
69
|
+
var osName = browserData.os.split(' ')[0].toLowerCase();
|
|
70
|
+
this.html.classList.add(this.prefix + "os-" + osName);
|
|
71
|
+
this._osName = osName;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._osName = '';
|
|
75
|
+
}
|
|
76
|
+
// get browser name
|
|
77
|
+
if (browserData === null || browserData === void 0 ? void 0 : browserData.name) {
|
|
78
|
+
var browserName = browserData.name.toLowerCase();
|
|
79
|
+
this.html.classList.add(this.prefix + "browser-" + browserName);
|
|
80
|
+
this._browserName = browserName;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this._browserName = '';
|
|
84
|
+
}
|
|
85
|
+
// browserData
|
|
86
|
+
// create default helpers
|
|
87
|
+
this._pageLoad = new PageLoad_1.PageLoad();
|
|
88
|
+
this._viewport = new Viewport_1.Viewport();
|
|
89
|
+
}
|
|
90
|
+
Object.defineProperty(Application.prototype, "prop", {
|
|
91
|
+
/**
|
|
92
|
+
* Application properties.
|
|
93
|
+
*/
|
|
94
|
+
get: function () {
|
|
95
|
+
return this._prop;
|
|
96
|
+
},
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(Application.prototype, "defaultProp", {
|
|
101
|
+
/**
|
|
102
|
+
* Default properties.
|
|
103
|
+
*/
|
|
104
|
+
get: function () {
|
|
105
|
+
return {
|
|
106
|
+
tablet: 1199,
|
|
107
|
+
phone: 899,
|
|
108
|
+
prefix: 'v-',
|
|
109
|
+
easing: [0.25, 0.1, 0.25, 1],
|
|
110
|
+
viewportResizeTimeout: 0,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
enumerable: false,
|
|
114
|
+
configurable: true
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(Application.prototype, "prefix", {
|
|
117
|
+
get: function () {
|
|
118
|
+
return this._prefix;
|
|
119
|
+
},
|
|
120
|
+
enumerable: false,
|
|
121
|
+
configurable: true
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(Application.prototype, "isPhone", {
|
|
124
|
+
get: function () {
|
|
125
|
+
return this._isPhone;
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(Application.prototype, "isTablet", {
|
|
131
|
+
get: function () {
|
|
132
|
+
return this._isTablet;
|
|
133
|
+
},
|
|
134
|
+
enumerable: false,
|
|
135
|
+
configurable: true
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(Application.prototype, "isMobile", {
|
|
138
|
+
get: function () {
|
|
139
|
+
return this._isMobile;
|
|
140
|
+
},
|
|
141
|
+
enumerable: false,
|
|
142
|
+
configurable: true
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(Application.prototype, "isDesktop", {
|
|
145
|
+
get: function () {
|
|
146
|
+
return this._isDesktop;
|
|
147
|
+
},
|
|
148
|
+
enumerable: false,
|
|
149
|
+
configurable: true
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(Application.prototype, "osName", {
|
|
152
|
+
get: function () {
|
|
153
|
+
return this._osName;
|
|
154
|
+
},
|
|
155
|
+
enumerable: false,
|
|
156
|
+
configurable: true
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(Application.prototype, "browserName", {
|
|
159
|
+
get: function () {
|
|
160
|
+
return this._browserName;
|
|
161
|
+
},
|
|
162
|
+
enumerable: false,
|
|
163
|
+
configurable: true
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(Application.prototype, "doc", {
|
|
166
|
+
/**
|
|
167
|
+
* Get document element.
|
|
168
|
+
*/
|
|
169
|
+
get: function () {
|
|
170
|
+
return document;
|
|
171
|
+
},
|
|
172
|
+
enumerable: false,
|
|
173
|
+
configurable: true
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(Application.prototype, "html", {
|
|
176
|
+
/**
|
|
177
|
+
* Get HTML element
|
|
178
|
+
*/
|
|
179
|
+
get: function () {
|
|
180
|
+
return document.documentElement;
|
|
181
|
+
},
|
|
182
|
+
enumerable: false,
|
|
183
|
+
configurable: true
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(Application.prototype, "body", {
|
|
186
|
+
/**
|
|
187
|
+
* Get body element.
|
|
188
|
+
*/
|
|
189
|
+
get: function () {
|
|
190
|
+
return document.body;
|
|
191
|
+
},
|
|
192
|
+
enumerable: false,
|
|
193
|
+
configurable: true
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(Application.prototype, "pages", {
|
|
196
|
+
/**
|
|
197
|
+
* Get an array of existing pages.
|
|
198
|
+
* A new element is added to the array when {@linkcode Vevet.Page.create} is called.
|
|
199
|
+
*/
|
|
200
|
+
get: function () {
|
|
201
|
+
return this._pages;
|
|
202
|
+
},
|
|
203
|
+
enumerable: false,
|
|
204
|
+
configurable: true
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(Application.prototype, "page", {
|
|
207
|
+
/**
|
|
208
|
+
* Get the current page instance.
|
|
209
|
+
*/
|
|
210
|
+
get: function () {
|
|
211
|
+
return this._page;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Set the current page instance.
|
|
215
|
+
*/
|
|
216
|
+
set: function (val) {
|
|
217
|
+
this._page = val;
|
|
218
|
+
},
|
|
219
|
+
enumerable: false,
|
|
220
|
+
configurable: true
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* Action on page created
|
|
224
|
+
*/
|
|
225
|
+
Application.prototype.onPageCreated = function () {
|
|
226
|
+
var _this = this;
|
|
227
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
228
|
+
if (_this._page) {
|
|
229
|
+
_this._page.onCreate().then(function () {
|
|
230
|
+
resolve(_this.page);
|
|
231
|
+
});
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
setTimeout(function () {
|
|
235
|
+
_this.onPageCreated().then(function () {
|
|
236
|
+
resolve(_this.page);
|
|
237
|
+
});
|
|
238
|
+
}, 30);
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Action on page shown
|
|
243
|
+
*/
|
|
244
|
+
Application.prototype.onPageShown = function () {
|
|
245
|
+
var _this = this;
|
|
246
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
247
|
+
_this.onPageCreated().then(function () {
|
|
248
|
+
if (_this._page) {
|
|
249
|
+
_this._page.onShow().then(function () {
|
|
250
|
+
resolve(_this.page);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
Object.defineProperty(Application.prototype, "pageLoad", {
|
|
257
|
+
get: function () {
|
|
258
|
+
return this._pageLoad;
|
|
259
|
+
},
|
|
260
|
+
enumerable: false,
|
|
261
|
+
configurable: true
|
|
262
|
+
});
|
|
263
|
+
/**
|
|
264
|
+
* Action on page laoded
|
|
265
|
+
*/
|
|
266
|
+
Application.prototype.onPageLoaded = function () {
|
|
267
|
+
var _this = this;
|
|
268
|
+
return new p_cancelable_1.default(function (resolve) {
|
|
269
|
+
_this._pageLoad.onLoaded(function () {
|
|
270
|
+
resolve();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
Object.defineProperty(Application.prototype, "viewport", {
|
|
275
|
+
get: function () {
|
|
276
|
+
return this._viewport;
|
|
277
|
+
},
|
|
278
|
+
enumerable: false,
|
|
279
|
+
configurable: true
|
|
280
|
+
});
|
|
281
|
+
/**
|
|
282
|
+
* Defines that you're using Vevet.
|
|
283
|
+
*/
|
|
284
|
+
Application.prototype._sayHi = function () {
|
|
285
|
+
var msg = 'Vevet';
|
|
286
|
+
var style = [
|
|
287
|
+
'padding: 1rem 1.5rem;',
|
|
288
|
+
'background: #5F2580;',
|
|
289
|
+
'font: 1rem/1 Arial;',
|
|
290
|
+
'color: #ffffff;',
|
|
291
|
+
].join('');
|
|
292
|
+
// eslint-disable-next-line no-console
|
|
293
|
+
console.log('%c%s', style, msg);
|
|
294
|
+
};
|
|
295
|
+
return Application;
|
|
296
|
+
}());
|
|
297
|
+
exports.Application = Application;
|
|
@@ -0,0 +1,74 @@
|
|
|
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.PageLoad = void 0;
|
|
19
|
+
var Callbacks_1 = require("../../base/Callbacks");
|
|
20
|
+
/**
|
|
21
|
+
* Callbacks on page loaded.
|
|
22
|
+
*/
|
|
23
|
+
var PageLoad = /** @class */ (function (_super) {
|
|
24
|
+
__extends(PageLoad, _super);
|
|
25
|
+
function PageLoad() {
|
|
26
|
+
var _this = _super.call(this, false) || this;
|
|
27
|
+
_this._loaded = false;
|
|
28
|
+
_this._init();
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(PageLoad.prototype, "loaded", {
|
|
32
|
+
get: function () {
|
|
33
|
+
return this._loaded;
|
|
34
|
+
},
|
|
35
|
+
enumerable: false,
|
|
36
|
+
configurable: true
|
|
37
|
+
});
|
|
38
|
+
PageLoad.prototype._setEvents = function () {
|
|
39
|
+
var _this = this;
|
|
40
|
+
if (document.readyState === 'complete') {
|
|
41
|
+
this._handleLoaded();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
window.addEventListener('load', function () {
|
|
45
|
+
_this._handleLoaded();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* When the page is loaded.
|
|
51
|
+
*/
|
|
52
|
+
PageLoad.prototype._handleLoaded = function () {
|
|
53
|
+
var app = this._app;
|
|
54
|
+
var prefix = app.prefix;
|
|
55
|
+
this._loaded = true;
|
|
56
|
+
app.html.classList.remove(prefix + "loading");
|
|
57
|
+
app.body.classList.remove(prefix + "loading");
|
|
58
|
+
app.html.classList.add(prefix + "loaded");
|
|
59
|
+
this.tbt('', false);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Add a callback on page load.
|
|
63
|
+
* If the page is already loaded, the callback will be immediately triggered.
|
|
64
|
+
*/
|
|
65
|
+
PageLoad.prototype.onLoaded = function (callback) {
|
|
66
|
+
if (this.loaded) {
|
|
67
|
+
callback();
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return this.add('', callback.bind(this));
|
|
71
|
+
};
|
|
72
|
+
return PageLoad;
|
|
73
|
+
}(Callbacks_1.Callbacks));
|
|
74
|
+
exports.PageLoad = PageLoad;
|
|
@@ -0,0 +1,303 @@
|
|
|
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.Viewport = void 0;
|
|
19
|
+
var Callbacks_1 = require("../../base/Callbacks");
|
|
20
|
+
var common_1 = require("../../utils/common");
|
|
21
|
+
/**
|
|
22
|
+
* Viewport size types
|
|
23
|
+
*/
|
|
24
|
+
var SizeTypes;
|
|
25
|
+
(function (SizeTypes) {
|
|
26
|
+
SizeTypes["Desktop"] = "desktop";
|
|
27
|
+
SizeTypes["Tablet"] = "tablet";
|
|
28
|
+
SizeTypes["Phone"] = "phone";
|
|
29
|
+
})(SizeTypes || (SizeTypes = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Orientation types
|
|
32
|
+
*/
|
|
33
|
+
var OrientationTypes;
|
|
34
|
+
(function (OrientationTypes) {
|
|
35
|
+
OrientationTypes["Landscape"] = "landscape";
|
|
36
|
+
OrientationTypes["Portrait"] = "portrait";
|
|
37
|
+
})(OrientationTypes || (OrientationTypes = {}));
|
|
38
|
+
/**
|
|
39
|
+
* Callbacks on window resize.
|
|
40
|
+
* Here the names of the OS, Browser, and Device are also available. <br>
|
|
41
|
+
*/
|
|
42
|
+
var Viewport = /** @class */ (function (_super) {
|
|
43
|
+
__extends(Viewport, _super);
|
|
44
|
+
function Viewport() {
|
|
45
|
+
var _this = _super.call(this, false) || this;
|
|
46
|
+
_this._width = 0;
|
|
47
|
+
_this._height = 0;
|
|
48
|
+
_this._prevSize = { w: 0, h: 0 };
|
|
49
|
+
_this._isDesktop = false;
|
|
50
|
+
_this._isTablet = false;
|
|
51
|
+
_this._isPhone = false;
|
|
52
|
+
_this._init();
|
|
53
|
+
return _this;
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(Viewport.prototype, "width", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._width;
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(Viewport.prototype, "height", {
|
|
63
|
+
get: function () {
|
|
64
|
+
return this._height;
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(Viewport.prototype, "vw", {
|
|
70
|
+
/**
|
|
71
|
+
* Get VW value
|
|
72
|
+
*/
|
|
73
|
+
get: function () {
|
|
74
|
+
return this.width / 100;
|
|
75
|
+
},
|
|
76
|
+
enumerable: false,
|
|
77
|
+
configurable: true
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(Viewport.prototype, "vh", {
|
|
80
|
+
/**
|
|
81
|
+
* Get VH value
|
|
82
|
+
*/
|
|
83
|
+
get: function () {
|
|
84
|
+
return this.height / 100;
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(Viewport.prototype, "prevSize", {
|
|
90
|
+
/**
|
|
91
|
+
* Get previous Viewport size
|
|
92
|
+
*/
|
|
93
|
+
get: function () {
|
|
94
|
+
return this._prevSize;
|
|
95
|
+
},
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(Viewport.prototype, "isLandscape", {
|
|
100
|
+
/**
|
|
101
|
+
* If width greater than height.
|
|
102
|
+
*/
|
|
103
|
+
get: function () {
|
|
104
|
+
return this.width > this.height;
|
|
105
|
+
},
|
|
106
|
+
enumerable: false,
|
|
107
|
+
configurable: true
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(Viewport.prototype, "isPortrait", {
|
|
110
|
+
/**
|
|
111
|
+
* If width less than height.
|
|
112
|
+
*/
|
|
113
|
+
get: function () {
|
|
114
|
+
return this.width < this.height;
|
|
115
|
+
},
|
|
116
|
+
enumerable: false,
|
|
117
|
+
configurable: true
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(Viewport.prototype, "isDesktop", {
|
|
120
|
+
get: function () {
|
|
121
|
+
return this._isDesktop;
|
|
122
|
+
},
|
|
123
|
+
enumerable: false,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(Viewport.prototype, "isTablet", {
|
|
127
|
+
get: function () {
|
|
128
|
+
return this._isTablet;
|
|
129
|
+
},
|
|
130
|
+
enumerable: false,
|
|
131
|
+
configurable: true
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(Viewport.prototype, "isPhone", {
|
|
134
|
+
get: function () {
|
|
135
|
+
return this._isPhone;
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(Viewport.prototype, "dpr", {
|
|
141
|
+
/**
|
|
142
|
+
* Device pixel ratio
|
|
143
|
+
*/
|
|
144
|
+
get: function () {
|
|
145
|
+
if (typeof window.devicePixelRatio !== 'undefined') {
|
|
146
|
+
return window.devicePixelRatio;
|
|
147
|
+
}
|
|
148
|
+
return 1;
|
|
149
|
+
},
|
|
150
|
+
enumerable: false,
|
|
151
|
+
configurable: true
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(Viewport.prototype, "lowerDesktopDPR", {
|
|
154
|
+
/**
|
|
155
|
+
* Device pixel ratio. For non-mobile devices it is always 1.
|
|
156
|
+
*/
|
|
157
|
+
get: function () {
|
|
158
|
+
if (this._app.isDesktop) {
|
|
159
|
+
return 1;
|
|
160
|
+
}
|
|
161
|
+
return this.dpr;
|
|
162
|
+
},
|
|
163
|
+
enumerable: false,
|
|
164
|
+
configurable: true
|
|
165
|
+
});
|
|
166
|
+
// Extra constructor
|
|
167
|
+
Viewport.prototype._constructor = function () {
|
|
168
|
+
_super.prototype._constructor.call(this);
|
|
169
|
+
this._setValues();
|
|
170
|
+
};
|
|
171
|
+
// Set events on resize
|
|
172
|
+
Viewport.prototype._setEvents = function () {
|
|
173
|
+
var _this = this;
|
|
174
|
+
window.addEventListener('resize', function () {
|
|
175
|
+
common_1.timeoutCallback(function () {
|
|
176
|
+
_this._onResize();
|
|
177
|
+
}, _this._app.prop.viewportResizeTimeout);
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Set viewport values
|
|
182
|
+
*/
|
|
183
|
+
Viewport.prototype._setValues = function () {
|
|
184
|
+
var app = this._app;
|
|
185
|
+
var html = app.html;
|
|
186
|
+
var appProp = app.prop;
|
|
187
|
+
// set sizes
|
|
188
|
+
this._width = html.clientWidth;
|
|
189
|
+
this._height = html.clientHeight;
|
|
190
|
+
this._prevSize = {
|
|
191
|
+
w: this._width,
|
|
192
|
+
h: this._height,
|
|
193
|
+
};
|
|
194
|
+
// size values
|
|
195
|
+
var width = this.width;
|
|
196
|
+
this._isDesktop = width >= appProp.tablet;
|
|
197
|
+
this._isTablet = width <= appProp.tablet && width > appProp.phone;
|
|
198
|
+
this._isPhone = width <= appProp.phone;
|
|
199
|
+
// update other values
|
|
200
|
+
this._updateClasses();
|
|
201
|
+
this._updateCSSVars();
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Change classes of the document element.
|
|
205
|
+
*/
|
|
206
|
+
Viewport.prototype._updateClasses = function () {
|
|
207
|
+
// set viewport type
|
|
208
|
+
var viewportSizeTypes = [
|
|
209
|
+
SizeTypes.Desktop,
|
|
210
|
+
SizeTypes.Tablet,
|
|
211
|
+
SizeTypes.Phone,
|
|
212
|
+
];
|
|
213
|
+
if (this.isDesktop) {
|
|
214
|
+
this._updateBreakpointClasses(SizeTypes.Desktop, viewportSizeTypes);
|
|
215
|
+
}
|
|
216
|
+
else if (this.isTablet) {
|
|
217
|
+
this._updateBreakpointClasses(SizeTypes.Tablet, viewportSizeTypes);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this._updateBreakpointClasses(SizeTypes.Phone, viewportSizeTypes);
|
|
221
|
+
}
|
|
222
|
+
// set orientation type
|
|
223
|
+
var orientationTypes = [
|
|
224
|
+
OrientationTypes.Landscape,
|
|
225
|
+
OrientationTypes.Portrait,
|
|
226
|
+
];
|
|
227
|
+
if (this.isLandscape) {
|
|
228
|
+
this._updateBreakpointClasses(OrientationTypes.Landscape, orientationTypes);
|
|
229
|
+
}
|
|
230
|
+
else if (this.isPortrait) {
|
|
231
|
+
this._updateBreakpointClasses(OrientationTypes.Portrait, orientationTypes);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
this._updateBreakpointClasses('', orientationTypes);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Change breakpoint classes of the document element.
|
|
239
|
+
*/
|
|
240
|
+
Viewport.prototype._updateBreakpointClasses = function (activeType, types) {
|
|
241
|
+
var html = this._app.html;
|
|
242
|
+
var prefix = this._app.prefix;
|
|
243
|
+
types.forEach(function (type) {
|
|
244
|
+
if (type === activeType) {
|
|
245
|
+
html.classList.add(prefix + "viewport-" + type);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
html.classList.remove(prefix + "viewport-" + type);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Update CSS vars
|
|
254
|
+
*/
|
|
255
|
+
Viewport.prototype._updateCSSVars = function () {
|
|
256
|
+
var html = this._app.html;
|
|
257
|
+
html.style.setProperty('--vw', this.vw + "px");
|
|
258
|
+
html.style.setProperty('--vh', this.vh + "px");
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Launch callbacks on resize.
|
|
262
|
+
*/
|
|
263
|
+
Viewport.prototype._onResize = function () {
|
|
264
|
+
// copy previous values
|
|
265
|
+
var prevWidth = this._prevSize.w;
|
|
266
|
+
var prevHeight = this._prevSize.h;
|
|
267
|
+
// set viewport values
|
|
268
|
+
this._setValues();
|
|
269
|
+
// copy size
|
|
270
|
+
var _a = this, width = _a.width, height = _a.height;
|
|
271
|
+
// get changes in viewport
|
|
272
|
+
var changes = {
|
|
273
|
+
widthChanged: width !== prevWidth,
|
|
274
|
+
heightChanged: height !== prevHeight,
|
|
275
|
+
orientationChanged: (width > height) !== (prevWidth > prevHeight),
|
|
276
|
+
};
|
|
277
|
+
// only when width is changed
|
|
278
|
+
if (width !== prevWidth && height === prevHeight) {
|
|
279
|
+
this.tbt('w_', changes);
|
|
280
|
+
}
|
|
281
|
+
// only when height is changed
|
|
282
|
+
if (height !== prevHeight && width === prevWidth) {
|
|
283
|
+
this.tbt('h_', changes);
|
|
284
|
+
}
|
|
285
|
+
// when height & width are changed
|
|
286
|
+
if (width !== prevWidth && height !== prevHeight) {
|
|
287
|
+
this.tbt('wh', changes);
|
|
288
|
+
this.tbt('hw', changes);
|
|
289
|
+
}
|
|
290
|
+
// when width is changed
|
|
291
|
+
if (width !== prevWidth) {
|
|
292
|
+
this.tbt('w', changes);
|
|
293
|
+
}
|
|
294
|
+
// when height changed
|
|
295
|
+
if (height !== prevHeight) {
|
|
296
|
+
this.tbt('h', changes);
|
|
297
|
+
}
|
|
298
|
+
// on any change
|
|
299
|
+
this.tbt('', changes);
|
|
300
|
+
};
|
|
301
|
+
return Viewport;
|
|
302
|
+
}(Callbacks_1.Callbacks));
|
|
303
|
+
exports.Viewport = Viewport;
|