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,385 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addEventListener, IAddEventListener, IAddEventListenerOptions, ListenerElement,
|
|
3
|
+
} from 'vevet-dom';
|
|
4
|
+
import { Callbacks, NCallbacks } from './Callbacks';
|
|
5
|
+
import { MutableProp, NMutableProp } from './MutableProp';
|
|
6
|
+
import { Application } from '../app/Application';
|
|
7
|
+
import mergeWithoutArrays from '../utils/common/mergeWithoutArrays';
|
|
8
|
+
import { Viewport } from '../app/events/Viewport';
|
|
9
|
+
import { RequiredModuleProp } from '../utils/types/utility';
|
|
10
|
+
import { throwVevetAppError } from '../utils/errors';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export namespace NModule {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Mutable Properties (may change on window resize or through {@linkcode Module.changeProp})
|
|
18
|
+
*/
|
|
19
|
+
export interface ChangeableProp { }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Static properties
|
|
23
|
+
*/
|
|
24
|
+
export interface StaticProp {
|
|
25
|
+
/**
|
|
26
|
+
* Parent module
|
|
27
|
+
*/
|
|
28
|
+
parent?: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Available callbacks
|
|
33
|
+
*/
|
|
34
|
+
export interface CallbacksTypes extends NCallbacks.CallbacksTypes {
|
|
35
|
+
'destroy': false;
|
|
36
|
+
'changeProp': false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A class for modules.
|
|
45
|
+
*/
|
|
46
|
+
export class Module<
|
|
47
|
+
/**
|
|
48
|
+
* Static Properties (they never change)
|
|
49
|
+
*/
|
|
50
|
+
StaticProp extends NModule.StaticProp = NModule.StaticProp,
|
|
51
|
+
/**
|
|
52
|
+
* Mutable Properties
|
|
53
|
+
* (may change on window resize or through {@linkcode Module.changeProp})
|
|
54
|
+
*/
|
|
55
|
+
ChangeableProp extends NModule.ChangeableProp = NModule.ChangeableProp,
|
|
56
|
+
/**
|
|
57
|
+
* Module Callbacks
|
|
58
|
+
*/
|
|
59
|
+
CallbacksTypes extends NModule.CallbacksTypes = NModule.CallbacksTypes,
|
|
60
|
+
> {
|
|
61
|
+
/**
|
|
62
|
+
* Get Default properties (should be extended)
|
|
63
|
+
*/
|
|
64
|
+
protected _getDefaultProp <
|
|
65
|
+
T extends RequiredModuleProp<StaticProp & ChangeableProp>
|
|
66
|
+
> (): T {
|
|
67
|
+
return {
|
|
68
|
+
parent: false,
|
|
69
|
+
} as T;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Current properties
|
|
74
|
+
*/
|
|
75
|
+
get prop (): RequiredModuleProp<(StaticProp & ChangeableProp)> {
|
|
76
|
+
return this._mutableProp.prop as RequiredModuleProp<(StaticProp & ChangeableProp)>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Responsive properties
|
|
81
|
+
*/
|
|
82
|
+
protected _mutableProp: MutableProp<
|
|
83
|
+
StaticProp,
|
|
84
|
+
ChangeableProp
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Module Callbacks
|
|
91
|
+
*/
|
|
92
|
+
protected _callbacks: Callbacks<CallbacksTypes>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Module Callbacks
|
|
96
|
+
*/
|
|
97
|
+
get callbacks () {
|
|
98
|
+
return this._callbacks;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Module listeners
|
|
105
|
+
*/
|
|
106
|
+
protected _listeners: IAddEventListener[];
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Vevet Application
|
|
112
|
+
*/
|
|
113
|
+
protected _app!: Application;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Module prefix
|
|
117
|
+
*/
|
|
118
|
+
get prefix (): string {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get module name
|
|
124
|
+
*/
|
|
125
|
+
get name () {
|
|
126
|
+
return this.constructor.name;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* If the module is initialized
|
|
131
|
+
*/
|
|
132
|
+
protected _inited = false;
|
|
133
|
+
get inited () {
|
|
134
|
+
return this._inited;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* If the module is destroyed
|
|
139
|
+
*/
|
|
140
|
+
protected _destroyed: boolean;
|
|
141
|
+
get destroyed () {
|
|
142
|
+
return this._destroyed;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @example
|
|
149
|
+
* const mod = new Module();
|
|
150
|
+
*/
|
|
151
|
+
constructor (
|
|
152
|
+
/**
|
|
153
|
+
* Properties on script start
|
|
154
|
+
*/
|
|
155
|
+
initialProp?: (StaticProp & ChangeableProp),
|
|
156
|
+
/**
|
|
157
|
+
* Defines if you need to call {@linkcode Module.init} at the constructor's end.
|
|
158
|
+
* If you want to add responsive properties, set this argument to FALSE.
|
|
159
|
+
*/
|
|
160
|
+
init = true,
|
|
161
|
+
) {
|
|
162
|
+
// set vars
|
|
163
|
+
if (window.vevetApp) {
|
|
164
|
+
this._app = window.vevetApp;
|
|
165
|
+
} else {
|
|
166
|
+
throwVevetAppError();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// set default vars
|
|
170
|
+
this._destroyed = false;
|
|
171
|
+
this._listeners = [];
|
|
172
|
+
|
|
173
|
+
// create callbacks
|
|
174
|
+
this._callbacks = new Callbacks<CallbacksTypes>();
|
|
175
|
+
|
|
176
|
+
// create mutable properties
|
|
177
|
+
const prop = mergeWithoutArrays(this._getDefaultProp(), initialProp || {});
|
|
178
|
+
this._mutableProp = new MutableProp(
|
|
179
|
+
prop as (StaticProp & ChangeableProp),
|
|
180
|
+
this._onPropResponsive.bind(this),
|
|
181
|
+
this._onPropChange.bind(this),
|
|
182
|
+
this.name,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
if (init) {
|
|
186
|
+
this.init();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Add responsive rules
|
|
194
|
+
*/
|
|
195
|
+
public addResponsiveProp (
|
|
196
|
+
rules: NMutableProp.Responsive<ChangeableProp>,
|
|
197
|
+
) {
|
|
198
|
+
if (this._inited) {
|
|
199
|
+
throw new Error('Responsive properties cannot be added because the class instance is already initialized');
|
|
200
|
+
} else {
|
|
201
|
+
this._mutableProp.addResponsiveProp(rules);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Change module properties.
|
|
207
|
+
* @example
|
|
208
|
+
*
|
|
209
|
+
* // changing properties
|
|
210
|
+
* // let's imagine that the module has the following properties:
|
|
211
|
+
* prop = {
|
|
212
|
+
* name: 'module',
|
|
213
|
+
* cute: true
|
|
214
|
+
* };
|
|
215
|
+
* // we can change some properties in it: whether one or several properties
|
|
216
|
+
* // after the properties are changed, the method _onPropChange is called.
|
|
217
|
+
* module.changeProp({
|
|
218
|
+
* cute: false
|
|
219
|
+
* });
|
|
220
|
+
*/
|
|
221
|
+
public changeProp (
|
|
222
|
+
prop: ChangeableProp = {} as ChangeableProp,
|
|
223
|
+
) {
|
|
224
|
+
this._mutableProp.changeProp(prop);
|
|
225
|
+
this._callbacks.tbt('changeProp', false);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The method that is called on window resize and properties change.
|
|
230
|
+
*/
|
|
231
|
+
protected _onPropResponsive () {
|
|
232
|
+
this._onPropMutate();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The method that is called on properties change.
|
|
237
|
+
*/
|
|
238
|
+
protected _onPropChange (
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
240
|
+
changedProp: ChangeableProp,
|
|
241
|
+
) {
|
|
242
|
+
this._onPropMutate();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The method that is called on properties change.
|
|
247
|
+
*/
|
|
248
|
+
protected _onPropMutate () { }
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Initializes the class.
|
|
254
|
+
*/
|
|
255
|
+
public init () {
|
|
256
|
+
// return if the module is already initialized
|
|
257
|
+
if (this._inited) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this._inited = true;
|
|
261
|
+
|
|
262
|
+
// continue initializing
|
|
263
|
+
this._constructor();
|
|
264
|
+
this._setEvents();
|
|
265
|
+
|
|
266
|
+
// destroy the current module on parent destroy
|
|
267
|
+
if (this.prop.parent) {
|
|
268
|
+
this.prop.parent.addCallback('destroy', () => {
|
|
269
|
+
this.destroy();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Extra constructor
|
|
276
|
+
*/
|
|
277
|
+
protected _constructor () {
|
|
278
|
+
// code
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Set events
|
|
283
|
+
*/
|
|
284
|
+
protected _setEvents () {
|
|
285
|
+
// code
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Viewport callbacks
|
|
292
|
+
*/
|
|
293
|
+
protected _viewportCallbacks: NCallbacks.AddedCallback[] = [];
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Add a viewport callback that will be removed on class destroy
|
|
297
|
+
* {@see Viewport}
|
|
298
|
+
*/
|
|
299
|
+
public addViewportCallback (
|
|
300
|
+
target: Parameters<Viewport['add']>[0],
|
|
301
|
+
func: Parameters<Viewport['add']>[1],
|
|
302
|
+
data: Parameters<Viewport['add']>[2] = {
|
|
303
|
+
name: this.constructor.name,
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
) {
|
|
307
|
+
const callback = this._app.viewport.add(target, func, data);
|
|
308
|
+
this._viewportCallbacks.push(callback);
|
|
309
|
+
return callback;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Add a module callback
|
|
316
|
+
* {@see Callbacks}
|
|
317
|
+
*/
|
|
318
|
+
public addCallback <Target extends keyof CallbacksTypes> (
|
|
319
|
+
target: Target,
|
|
320
|
+
func: NCallbacks.CallbackSettings<CallbacksTypes, Target>['do'],
|
|
321
|
+
data: NCallbacks.CallbackBaseSettings = {},
|
|
322
|
+
|
|
323
|
+
) {
|
|
324
|
+
const callback = this.callbacks.add(target, func, data);
|
|
325
|
+
return callback;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Add a DOM event listeners
|
|
332
|
+
*/
|
|
333
|
+
public addEventListeners <
|
|
334
|
+
El extends ListenerElement,
|
|
335
|
+
Target extends keyof HTMLElementEventMap,
|
|
336
|
+
Callback extends (evt: HTMLElementEventMap[Target]) => void,
|
|
337
|
+
> (
|
|
338
|
+
|
|
339
|
+
el: El,
|
|
340
|
+
target: Target,
|
|
341
|
+
callback: Callback,
|
|
342
|
+
options?: IAddEventListenerOptions): IAddEventListener {
|
|
343
|
+
const listener = addEventListener(el, target, callback, options);
|
|
344
|
+
this._listeners.push(listener);
|
|
345
|
+
|
|
346
|
+
return listener;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Destroy the module
|
|
353
|
+
*/
|
|
354
|
+
public destroy () {
|
|
355
|
+
if (this.destroyed) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
this._destroy();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Destroy the module
|
|
363
|
+
*/
|
|
364
|
+
protected _destroy () {
|
|
365
|
+
// destroy callbacks
|
|
366
|
+
this._callbacks.tbt('destroy', false);
|
|
367
|
+
this._callbacks.destroy();
|
|
368
|
+
|
|
369
|
+
// destroy mutable properties
|
|
370
|
+
this._mutableProp.destroy();
|
|
371
|
+
|
|
372
|
+
// destroy viewport callbacks
|
|
373
|
+
this._viewportCallbacks.forEach((callback) => {
|
|
374
|
+
callback.remove();
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// destroy all listeners
|
|
378
|
+
this._listeners.forEach((listener) => {
|
|
379
|
+
listener.remove();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// events
|
|
383
|
+
this._destroyed = true;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { Application } from '../app/Application';
|
|
2
|
+
import { mergeWithoutArrays } from '../utils/common';
|
|
3
|
+
import { NCallbacks } from './Callbacks';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export namespace NMutableProp {
|
|
8
|
+
|
|
9
|
+
export interface Responsive<S> {
|
|
10
|
+
/**
|
|
11
|
+
* Breakpoint on which the properties will change.
|
|
12
|
+
* Available breakpoints:
|
|
13
|
+
* <ul>
|
|
14
|
+
* <li>any number - width breakpoint</li>
|
|
15
|
+
* <li>'d' - for desktop size</li>
|
|
16
|
+
* <li>'t' - for tablet size</li>
|
|
17
|
+
* <li>'p' - for phone size</li>
|
|
18
|
+
* <li>'phone' - for phone devices</li>
|
|
19
|
+
* <li>'tablet' - for tablet devices</li>
|
|
20
|
+
* <li>'mobile' - for phone or tablet devices</li>
|
|
21
|
+
* </ul>
|
|
22
|
+
*/
|
|
23
|
+
breakpoint: number | 'd' | 't' | 'p' | 'phone' | 'tablet' | 'mobile';
|
|
24
|
+
settings: S;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A class for creating mutable properties that can change on window resize. <br><br>
|
|
33
|
+
*
|
|
34
|
+
* There are two ways to change properties:
|
|
35
|
+
* <ul>
|
|
36
|
+
* <li>
|
|
37
|
+
* To set a resize-listener on window (or use {@linkcode Viewport}).
|
|
38
|
+
* When the window is resized, change the properties with the help of
|
|
39
|
+
* {@linkcode MutableProp.changeProp}</li>
|
|
40
|
+
* <li>
|
|
41
|
+
* The second way is to use the MutableProp and add responsive properties
|
|
42
|
+
* with help of {@linkcode MutableProp.addResponsiveProp}.</li>
|
|
43
|
+
* </ul>
|
|
44
|
+
*/
|
|
45
|
+
export class MutableProp<
|
|
46
|
+
/**
|
|
47
|
+
* Static Properties (they never change)
|
|
48
|
+
*/
|
|
49
|
+
StaticProp extends Record<string, any>,
|
|
50
|
+
/**
|
|
51
|
+
* Mutable Properties
|
|
52
|
+
* (may change on window resize or through {@linkcode MutableProp.changeProp})
|
|
53
|
+
*/
|
|
54
|
+
ChangeableProp extends Record<string, any>,
|
|
55
|
+
> {
|
|
56
|
+
/**
|
|
57
|
+
* Vevet Application.
|
|
58
|
+
*/
|
|
59
|
+
protected _app: Application;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @description Reference properties.
|
|
63
|
+
* These properties may change only through {@linkcode MutableProp.changeProp}.
|
|
64
|
+
*/
|
|
65
|
+
protected _refProp: StaticProp & ChangeableProp;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Current properties.
|
|
69
|
+
* These properties may change both on {@linkcode MutableProp.changeProp} and resize.
|
|
70
|
+
*/
|
|
71
|
+
protected _prop: StaticProp & ChangeableProp;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A set of responsive rules
|
|
75
|
+
*/
|
|
76
|
+
protected _responsiveRules: NMutableProp.Responsive<ChangeableProp>[] = [];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get current properties
|
|
80
|
+
*/
|
|
81
|
+
get prop () {
|
|
82
|
+
return this._prop;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Viewport callback
|
|
87
|
+
*/
|
|
88
|
+
protected _viewportCallback: NCallbacks.AddedCallback | undefined;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @example
|
|
94
|
+
* const static = {
|
|
95
|
+
* myProp: true,
|
|
96
|
+
* };
|
|
97
|
+
* const responsive = [
|
|
98
|
+
* {
|
|
99
|
+
* breakpoint: 'm',
|
|
100
|
+
* settings: {
|
|
101
|
+
* myProp: false
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* ];
|
|
105
|
+
* const prop = new MutableProp(static, responsive);
|
|
106
|
+
*/
|
|
107
|
+
constructor (
|
|
108
|
+
/**
|
|
109
|
+
* The properties that were set while initialization.
|
|
110
|
+
* These properties do not change throughout time.
|
|
111
|
+
*/
|
|
112
|
+
protected _initProp: (StaticProp & ChangeableProp),
|
|
113
|
+
/**
|
|
114
|
+
* A callback that is launched when properties are changed on window resize
|
|
115
|
+
*/
|
|
116
|
+
protected _onResponsive: () => void = () => {},
|
|
117
|
+
/**
|
|
118
|
+
* A callback that is launched when properties are changed
|
|
119
|
+
* through {@linkcode MutableProp.changeProp}
|
|
120
|
+
*/
|
|
121
|
+
protected _onChange: (prop: ChangeableProp) => void = () => {},
|
|
122
|
+
/**
|
|
123
|
+
* Name of the responsive properties.
|
|
124
|
+
*/
|
|
125
|
+
protected _name = 'Responsive Prop',
|
|
126
|
+
) {
|
|
127
|
+
this._app = window.vevetApp;
|
|
128
|
+
this._refProp = mergeWithoutArrays({}, _initProp);
|
|
129
|
+
this._prop = mergeWithoutArrays({}, _initProp);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Add responsive rules
|
|
136
|
+
*/
|
|
137
|
+
public addResponsiveProp (
|
|
138
|
+
rules: NMutableProp.Responsive<ChangeableProp>,
|
|
139
|
+
) {
|
|
140
|
+
this._responsiveRules.push(rules);
|
|
141
|
+
|
|
142
|
+
// add event on resize
|
|
143
|
+
if (typeof this._viewportCallback === 'undefined') {
|
|
144
|
+
this._viewportCallback = this._app.viewport.add('w', this._responseProp.bind(this, true), {
|
|
145
|
+
name: this._name,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// change properties according to the responsive prop
|
|
150
|
+
this._responseProp();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Change properties according to the "responsive" settings
|
|
157
|
+
* @param onResize - If the method was called on window resize.
|
|
158
|
+
*/
|
|
159
|
+
protected _responseProp (
|
|
160
|
+
onResize = false,
|
|
161
|
+
) {
|
|
162
|
+
const responsiveProp = this._responsiveRules;
|
|
163
|
+
|
|
164
|
+
// get sizes
|
|
165
|
+
const app = this._app;
|
|
166
|
+
const { viewport } = app;
|
|
167
|
+
const { width } = viewport;
|
|
168
|
+
let newProp: (StaticProp & ChangeableProp) | false = false;
|
|
169
|
+
const statProp = mergeWithoutArrays({}, this._refProp);
|
|
170
|
+
|
|
171
|
+
// go through all breakpoints
|
|
172
|
+
// and check if a proper breakpoint exists
|
|
173
|
+
responsiveProp.forEach((prop) => {
|
|
174
|
+
// copy settings
|
|
175
|
+
const { settings, breakpoint } = prop;
|
|
176
|
+
|
|
177
|
+
// if the breakpoint is a number
|
|
178
|
+
if (typeof breakpoint === 'number') {
|
|
179
|
+
if (width <= prop.breakpoint) {
|
|
180
|
+
newProp = mergeWithoutArrays(statProp, settings);
|
|
181
|
+
}
|
|
182
|
+
} else if (typeof breakpoint === 'string') {
|
|
183
|
+
const string = breakpoint.toLowerCase() as typeof breakpoint;
|
|
184
|
+
// viewport size
|
|
185
|
+
if (
|
|
186
|
+
(string === 'd' && viewport.isDesktop)
|
|
187
|
+
|| (string === 't' && viewport.isTablet)
|
|
188
|
+
|| (string === 'p' && viewport.isPhone)
|
|
189
|
+
) {
|
|
190
|
+
newProp = mergeWithoutArrays(statProp, settings);
|
|
191
|
+
}
|
|
192
|
+
// device type
|
|
193
|
+
if (
|
|
194
|
+
(string === 'phone' && app.isPhone)
|
|
195
|
+
|| (string === 'tablet' && app.isTablet)
|
|
196
|
+
|| (string === 'mobile' && app.isMobile)
|
|
197
|
+
) {
|
|
198
|
+
newProp = mergeWithoutArrays(statProp, settings);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// if there's no breakpoint, restore the props
|
|
204
|
+
if (!newProp) {
|
|
205
|
+
this._prop = mergeWithoutArrays(this._prop, this._refProp);
|
|
206
|
+
} else {
|
|
207
|
+
// otherwise, change the properties
|
|
208
|
+
this._prop = mergeWithoutArrays(this._prop, newProp);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// responsive callback
|
|
212
|
+
if (onResize) {
|
|
213
|
+
this._onResponsive();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* This method allows you to change the properties manually.
|
|
221
|
+
*/
|
|
222
|
+
public changeProp (
|
|
223
|
+
prop: ChangeableProp,
|
|
224
|
+
) {
|
|
225
|
+
this._prop = mergeWithoutArrays(this._prop, prop);
|
|
226
|
+
this._refProp = mergeWithoutArrays(this._refProp, prop);
|
|
227
|
+
|
|
228
|
+
// change prop callback
|
|
229
|
+
this._onChange(prop);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Destroy the responsive properties.
|
|
236
|
+
*/
|
|
237
|
+
public destroy () {
|
|
238
|
+
if (this._viewportCallback) {
|
|
239
|
+
this._viewportCallback.remove();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Module, NModule } from './Module';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export namespace NPlugin {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Static properties
|
|
9
|
+
*/
|
|
10
|
+
export interface StaticProp {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Changeable Properties
|
|
14
|
+
*/
|
|
15
|
+
export interface ChangeableProp {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Available callbacks
|
|
19
|
+
*/
|
|
20
|
+
export interface CallbacksTypes extends NModule.CallbacksTypes {}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A class for Plugins.
|
|
28
|
+
*/
|
|
29
|
+
export abstract class Plugin<
|
|
30
|
+
StaticProp extends NPlugin.StaticProp = NPlugin.StaticProp,
|
|
31
|
+
ChangeableProp extends NPlugin.ChangeableProp = NPlugin.ChangeableProp,
|
|
32
|
+
CallbacksTypes extends NPlugin.CallbacksTypes = NPlugin.CallbacksTypes,
|
|
33
|
+
Component = any
|
|
34
|
+
> extends Module <
|
|
35
|
+
StaticProp,
|
|
36
|
+
ChangeableProp,
|
|
37
|
+
CallbacksTypes
|
|
38
|
+
> {
|
|
39
|
+
constructor (
|
|
40
|
+
initialProp?: (StaticProp & ChangeableProp),
|
|
41
|
+
) {
|
|
42
|
+
super(initialProp, false);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
protected _component!: Component;
|
|
48
|
+
get component () {
|
|
49
|
+
return this._component;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Initializes the class
|
|
56
|
+
*/
|
|
57
|
+
public init () {
|
|
58
|
+
if (!this._component) {
|
|
59
|
+
throw new Error('Component is not set. Be sure that initlugin is called before.');
|
|
60
|
+
}
|
|
61
|
+
super.init();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Initialize the plugin
|
|
66
|
+
*/
|
|
67
|
+
public initPlugin (
|
|
68
|
+
parent: Component,
|
|
69
|
+
) {
|
|
70
|
+
if (this._inited) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._component = parent;
|
|
74
|
+
this.init();
|
|
75
|
+
}
|
|
76
|
+
}
|