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,344 @@
|
|
|
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.CustomCursor = void 0;
|
|
33
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
34
|
+
var AnimationFrame_1 = require("../animation-frame/AnimationFrame");
|
|
35
|
+
var Component_1 = require("../../base/Component");
|
|
36
|
+
var lerp_1 = __importDefault(require("../../utils/math/lerp"));
|
|
37
|
+
/**
|
|
38
|
+
* Creates a smooth custom cursor
|
|
39
|
+
*/
|
|
40
|
+
var CustomCursor = /** @class */ (function (_super) {
|
|
41
|
+
__extends(CustomCursor, _super);
|
|
42
|
+
function CustomCursor(initialProp, init) {
|
|
43
|
+
if (init === void 0) { init = true; }
|
|
44
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
45
|
+
// get cursor container
|
|
46
|
+
var container = vevet_dom_1.selectOne(_this.prop.container);
|
|
47
|
+
if (container) {
|
|
48
|
+
_this._container = container;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error("No cursor container for " + _this.prop.container);
|
|
52
|
+
}
|
|
53
|
+
_this._containerIsWindow = container instanceof Window;
|
|
54
|
+
// set default vars
|
|
55
|
+
_this._x = 0;
|
|
56
|
+
_this._xTarget = 0;
|
|
57
|
+
_this._y = 0;
|
|
58
|
+
_this._yTarget = 0;
|
|
59
|
+
_this._currentFPS = 60;
|
|
60
|
+
_this._canPlay = _this.prop.run;
|
|
61
|
+
// initialize the class
|
|
62
|
+
if (init) {
|
|
63
|
+
_this.init();
|
|
64
|
+
}
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
CustomCursor.prototype._getDefaultProp = function () {
|
|
68
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: window, run: true, hideNativeCursor: false, render: {
|
|
69
|
+
lerp: 0.2,
|
|
70
|
+
lerpToFixed: 2,
|
|
71
|
+
normalizeLerp: false,
|
|
72
|
+
}, autoStop: true });
|
|
73
|
+
};
|
|
74
|
+
Object.defineProperty(CustomCursor.prototype, "prefix", {
|
|
75
|
+
get: function () {
|
|
76
|
+
return this._app.prefix + "custom-cursor";
|
|
77
|
+
},
|
|
78
|
+
enumerable: false,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(CustomCursor.prototype, "container", {
|
|
82
|
+
/**
|
|
83
|
+
* Cursor container
|
|
84
|
+
*/
|
|
85
|
+
get: function () {
|
|
86
|
+
return this._container;
|
|
87
|
+
},
|
|
88
|
+
enumerable: false,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(CustomCursor.prototype, "eventsContainer", {
|
|
92
|
+
/**
|
|
93
|
+
* The element for events
|
|
94
|
+
*/
|
|
95
|
+
get: function () {
|
|
96
|
+
return this._container;
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(CustomCursor.prototype, "domContainer", {
|
|
102
|
+
/**
|
|
103
|
+
* The DOM parent for the cursor element
|
|
104
|
+
*/
|
|
105
|
+
get: function () {
|
|
106
|
+
if (this.container instanceof Window) {
|
|
107
|
+
return this._app.html;
|
|
108
|
+
}
|
|
109
|
+
return this.container;
|
|
110
|
+
},
|
|
111
|
+
enumerable: false,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(CustomCursor.prototype, "outerCursor", {
|
|
115
|
+
/**
|
|
116
|
+
* Cursor element (outer element)
|
|
117
|
+
*/
|
|
118
|
+
get: function () {
|
|
119
|
+
return this._outerCursor;
|
|
120
|
+
},
|
|
121
|
+
enumerable: false,
|
|
122
|
+
configurable: true
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(CustomCursor.prototype, "innerCursor", {
|
|
125
|
+
/**
|
|
126
|
+
* Cursor element (inner element)
|
|
127
|
+
*/
|
|
128
|
+
get: function () {
|
|
129
|
+
return this._innerCursor;
|
|
130
|
+
},
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: true
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(CustomCursor.prototype, "x", {
|
|
135
|
+
/**
|
|
136
|
+
* Current X coordinate relative to Window
|
|
137
|
+
*/
|
|
138
|
+
get: function () {
|
|
139
|
+
return this._x;
|
|
140
|
+
},
|
|
141
|
+
enumerable: false,
|
|
142
|
+
configurable: true
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(CustomCursor.prototype, "y", {
|
|
145
|
+
/**
|
|
146
|
+
* Current Y coordinate relative to Window
|
|
147
|
+
*/
|
|
148
|
+
get: function () {
|
|
149
|
+
return this._y;
|
|
150
|
+
},
|
|
151
|
+
enumerable: false,
|
|
152
|
+
configurable: true
|
|
153
|
+
});
|
|
154
|
+
// Extra constructor
|
|
155
|
+
CustomCursor.prototype._constructor = function () {
|
|
156
|
+
_super.prototype._constructor.call(this);
|
|
157
|
+
this._createCursor();
|
|
158
|
+
};
|
|
159
|
+
// Set Module Events
|
|
160
|
+
CustomCursor.prototype._setEvents = function () {
|
|
161
|
+
var _this = this;
|
|
162
|
+
_super.prototype._setEvents.call(this);
|
|
163
|
+
var domContainer = this.domContainer;
|
|
164
|
+
// create animation frame
|
|
165
|
+
this._animationFrame = new AnimationFrame_1.AnimationFrame();
|
|
166
|
+
this._animationFrame.addCallback('frame', function (data) {
|
|
167
|
+
_this._currentFPS = data.realFPS;
|
|
168
|
+
_this.render();
|
|
169
|
+
});
|
|
170
|
+
if (this._canPlay) {
|
|
171
|
+
this.enable();
|
|
172
|
+
}
|
|
173
|
+
// set mouse hover events
|
|
174
|
+
this.addEventListeners(domContainer, 'mouseenter', this._handleMouseEnter.bind(this));
|
|
175
|
+
this.addEventListeners(domContainer, 'mouseleave', this._handleMouseLeave.bind(this));
|
|
176
|
+
// set move events
|
|
177
|
+
this.addEventListeners(domContainer, 'mousemove', this._handleMouseMove.bind(this));
|
|
178
|
+
// set click events events
|
|
179
|
+
this.addEventListeners(domContainer, 'mousedown', this._handleMouseDown.bind(this));
|
|
180
|
+
this.addEventListeners(domContainer, 'mouseup', this._handleMouseUp.bind(this));
|
|
181
|
+
this.addEventListeners(window, 'blur', this._handleWindowBlur.bind(this));
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Create custom cursor
|
|
185
|
+
*/
|
|
186
|
+
CustomCursor.prototype._createCursor = function () {
|
|
187
|
+
var _a = this, prefix = _a.prefix, container = _a.container, domContainer = _a.domContainer;
|
|
188
|
+
// hide native cursor
|
|
189
|
+
if (this.prop.hideNativeCursor) {
|
|
190
|
+
domContainer.style.cursor = 'none';
|
|
191
|
+
domContainer.classList.add('hide-defaut-cursor');
|
|
192
|
+
}
|
|
193
|
+
// set classes
|
|
194
|
+
domContainer.classList.add(prefix + "-container");
|
|
195
|
+
// create cursor elements
|
|
196
|
+
this._outerCursor = vevet_dom_1.createElement('div', {
|
|
197
|
+
class: prefix + " " + (container instanceof Window ? 'in-window' : 'in-element') + " disabled",
|
|
198
|
+
parent: domContainer,
|
|
199
|
+
});
|
|
200
|
+
this._innerCursor = vevet_dom_1.createElement('div', {
|
|
201
|
+
class: prefix + "__inner disabled",
|
|
202
|
+
parent: this._outerCursor,
|
|
203
|
+
});
|
|
204
|
+
// launch events
|
|
205
|
+
this.callbacks.tbt('create', {
|
|
206
|
+
outerCursor: this.outerCursor,
|
|
207
|
+
innerCursor: this.innerCursor,
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Destroy the cursor
|
|
212
|
+
*/
|
|
213
|
+
CustomCursor.prototype._destroyCursor = function () {
|
|
214
|
+
var _a = this, prefix = _a.prefix, domContainer = _a.domContainer;
|
|
215
|
+
domContainer.style.cursor = '';
|
|
216
|
+
domContainer.classList.remove('hide-defaut-cursor');
|
|
217
|
+
domContainer.classList.remove(prefix + "-container");
|
|
218
|
+
this._outerCursor.remove();
|
|
219
|
+
this._innerCursor.remove();
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Event on mouse enter
|
|
223
|
+
*/
|
|
224
|
+
CustomCursor.prototype._handleMouseEnter = function (evt) {
|
|
225
|
+
// update coordinates
|
|
226
|
+
this._xTarget = evt.clientX;
|
|
227
|
+
this._x = this._xTarget;
|
|
228
|
+
this._yTarget = evt.clientY;
|
|
229
|
+
this._y = this._yTarget;
|
|
230
|
+
// set classes
|
|
231
|
+
this.outerCursor.classList.add('in-action');
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Event on mouse leave
|
|
235
|
+
*/
|
|
236
|
+
CustomCursor.prototype._handleMouseLeave = function () {
|
|
237
|
+
this.outerCursor.classList.remove('in-action');
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Event on mouse move
|
|
241
|
+
*/
|
|
242
|
+
CustomCursor.prototype._handleMouseMove = function (evt) {
|
|
243
|
+
this._xTarget = evt.clientX;
|
|
244
|
+
this._yTarget = evt.clientY;
|
|
245
|
+
// set classes
|
|
246
|
+
this.outerCursor.classList.add('in-action');
|
|
247
|
+
// launch animation
|
|
248
|
+
if (this._canPlay) {
|
|
249
|
+
this._animationFrame.play();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Event on mouse down
|
|
254
|
+
*/
|
|
255
|
+
CustomCursor.prototype._handleMouseDown = function (evt) {
|
|
256
|
+
if (evt.which === 1) {
|
|
257
|
+
this.outerCursor.classList.add('click');
|
|
258
|
+
this.innerCursor.classList.add('click');
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Event on mouse up
|
|
263
|
+
*/
|
|
264
|
+
CustomCursor.prototype._handleMouseUp = function () {
|
|
265
|
+
this.outerCursor.classList.remove('click');
|
|
266
|
+
this.innerCursor.classList.remove('click');
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Event on mouse down
|
|
270
|
+
*/
|
|
271
|
+
CustomCursor.prototype._handleWindowBlur = function () {
|
|
272
|
+
this._handleMouseUp();
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Render the scene
|
|
276
|
+
*/
|
|
277
|
+
CustomCursor.prototype.render = function () {
|
|
278
|
+
// props
|
|
279
|
+
var prop = this.prop;
|
|
280
|
+
var domContainer = this.domContainer;
|
|
281
|
+
var _a = prop.render, normalizeLerp = _a.normalizeLerp, ease = _a.lerp, lerpToFixed = _a.lerpToFixed;
|
|
282
|
+
var fpsMultiplier = normalizeLerp ? 60 / this._currentFPS : 1;
|
|
283
|
+
// interpolate coordinates
|
|
284
|
+
this._x = lerp_1.default(this._x, this._xTarget, ease * fpsMultiplier, 0.02);
|
|
285
|
+
this._y = lerp_1.default(this._y, this._yTarget, ease * fpsMultiplier, 0.02);
|
|
286
|
+
// round the values
|
|
287
|
+
if (typeof lerpToFixed === 'number') {
|
|
288
|
+
var fixed = Math.round(Math.abs(lerpToFixed));
|
|
289
|
+
this._x = parseFloat(this._x.toFixed(fixed));
|
|
290
|
+
this._y = parseFloat(this._y.toFixed(fixed));
|
|
291
|
+
}
|
|
292
|
+
// calcu;ate real coordinates
|
|
293
|
+
var x = this._x;
|
|
294
|
+
var y = this._y;
|
|
295
|
+
if (!this._containerIsWindow) {
|
|
296
|
+
var bounding = domContainer.getBoundingClientRect();
|
|
297
|
+
x -= bounding.left;
|
|
298
|
+
y -= bounding.top;
|
|
299
|
+
}
|
|
300
|
+
// update dom coordinates
|
|
301
|
+
this.outerCursor.style.transform = "translate(" + x + "px, " + y + "px)";
|
|
302
|
+
// auto stop
|
|
303
|
+
if (prop.autoStop
|
|
304
|
+
&& this._x === this._xTarget && this._y === this._yTarget) {
|
|
305
|
+
this._animationFrame.pause();
|
|
306
|
+
}
|
|
307
|
+
// launch render events
|
|
308
|
+
this._callbacks.tbt('render', { x: x, y: y });
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Enable cursor
|
|
312
|
+
*/
|
|
313
|
+
CustomCursor.prototype.enable = function () {
|
|
314
|
+
this._canPlay = true;
|
|
315
|
+
if (this._animationFrame.isPlaying) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this.outerCursor.classList.remove('disabled');
|
|
319
|
+
this.innerCursor.classList.remove('disabled');
|
|
320
|
+
this._animationFrame.play();
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Disable cursor
|
|
324
|
+
*/
|
|
325
|
+
CustomCursor.prototype.disable = function () {
|
|
326
|
+
this._canPlay = false;
|
|
327
|
+
if (!this._animationFrame.isPlaying) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.outerCursor.classList.add('disabled');
|
|
331
|
+
this.innerCursor.classList.add('disabled');
|
|
332
|
+
this._animationFrame.pause();
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Destroy the module
|
|
336
|
+
*/
|
|
337
|
+
CustomCursor.prototype._destroy = function () {
|
|
338
|
+
_super.prototype._destroy.call(this);
|
|
339
|
+
this._destroyCursor();
|
|
340
|
+
this._animationFrame.destroy();
|
|
341
|
+
};
|
|
342
|
+
return CustomCursor;
|
|
343
|
+
}(Component_1.Component));
|
|
344
|
+
exports.CustomCursor = CustomCursor;
|
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Dragger = void 0;
|
|
30
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
31
|
+
var Component_1 = require("../../base/Component");
|
|
32
|
+
/**
|
|
33
|
+
* Drag & Swipe events. An abstract class
|
|
34
|
+
*/
|
|
35
|
+
var Dragger = /** @class */ (function (_super) {
|
|
36
|
+
__extends(Dragger, _super);
|
|
37
|
+
function Dragger(initialProp, init) {
|
|
38
|
+
if (init === void 0) { init = true; }
|
|
39
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
40
|
+
// get container
|
|
41
|
+
_this._container = vevet_dom_1.selectOne(_this.prop.container);
|
|
42
|
+
if (!vevet_dom_1.isElement(_this._container) && !vevet_dom_1.isWindow(_this._container)) {
|
|
43
|
+
throw new Error('No container');
|
|
44
|
+
}
|
|
45
|
+
// set default vars
|
|
46
|
+
_this._runtimeEvents = [];
|
|
47
|
+
_this._isDragging = false;
|
|
48
|
+
_this._pointerID = null;
|
|
49
|
+
_this._coords = { x: 0, y: 0 };
|
|
50
|
+
_this._prevCoords = { x: 0, y: 0 };
|
|
51
|
+
_this._startCoords = { x: 0, y: 0 };
|
|
52
|
+
// initialize the class
|
|
53
|
+
if (init) {
|
|
54
|
+
_this.init();
|
|
55
|
+
}
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
Dragger.prototype._getDefaultProp = function () {
|
|
59
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#" + this.prefix, usePassive: false, enabled: true });
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(Dragger.prototype, "prefix", {
|
|
62
|
+
get: function () {
|
|
63
|
+
return this._app.prefix + "dragger";
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(Dragger.prototype, "container", {
|
|
69
|
+
/**
|
|
70
|
+
* Preloader container
|
|
71
|
+
*/
|
|
72
|
+
get: function () {
|
|
73
|
+
return this._container;
|
|
74
|
+
},
|
|
75
|
+
enumerable: false,
|
|
76
|
+
configurable: true
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(Dragger.prototype, "isDragging", {
|
|
79
|
+
/**
|
|
80
|
+
* If is dragging at the moment
|
|
81
|
+
*/
|
|
82
|
+
get: function () {
|
|
83
|
+
return this._isDragging;
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(Dragger.prototype, "coords", {
|
|
89
|
+
/**
|
|
90
|
+
* Current coordinates relative to the Window
|
|
91
|
+
*/
|
|
92
|
+
get: function () {
|
|
93
|
+
return this._coords;
|
|
94
|
+
},
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(Dragger.prototype, "startCoords", {
|
|
99
|
+
/**
|
|
100
|
+
* Coordinates on drag start
|
|
101
|
+
*/
|
|
102
|
+
get: function () {
|
|
103
|
+
return this._startCoords;
|
|
104
|
+
},
|
|
105
|
+
enumerable: false,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Set component events
|
|
110
|
+
*/
|
|
111
|
+
Dragger.prototype._setEvents = function () {
|
|
112
|
+
var container = this.container;
|
|
113
|
+
var usePassive = this.prop.usePassive;
|
|
114
|
+
this.addEventListeners(container, 'mousedown', this._handleStart.bind(this), { passive: usePassive });
|
|
115
|
+
this.addEventListeners(container, 'touchstart', this._handleStart.bind(this), { passive: usePassive });
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Add runtime events
|
|
119
|
+
*/
|
|
120
|
+
Dragger.prototype._addRuntimeEvents = function () {
|
|
121
|
+
var usePassive = this.prop.usePassive;
|
|
122
|
+
// end
|
|
123
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'mouseup', this._handleEnd.bind(this), {
|
|
124
|
+
passive: usePassive,
|
|
125
|
+
}));
|
|
126
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'touchend', this._handleEnd.bind(this), {
|
|
127
|
+
passive: usePassive,
|
|
128
|
+
}));
|
|
129
|
+
// cancel
|
|
130
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'touchcancel', this.cancel.bind(this), {
|
|
131
|
+
passive: usePassive,
|
|
132
|
+
}));
|
|
133
|
+
this._runtimeEvents.push(vevet_dom_1.addEventListener(window, 'blur', this.cancel.bind(this), {
|
|
134
|
+
passive: usePassive,
|
|
135
|
+
}));
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Remove runtime events
|
|
139
|
+
*/
|
|
140
|
+
Dragger.prototype._removeRuntimeEvents = function () {
|
|
141
|
+
this._runtimeEvents.forEach(function (event) {
|
|
142
|
+
event.remove();
|
|
143
|
+
});
|
|
144
|
+
this._runtimeEvents = [];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Normalize event data.
|
|
148
|
+
*/
|
|
149
|
+
Dragger.prototype._normalizeEvent = function (e) {
|
|
150
|
+
if (e.type.includes('touch')) {
|
|
151
|
+
var evt_1 = e;
|
|
152
|
+
var touch = evt_1.targetTouches[0] || evt_1.changedTouches[0];
|
|
153
|
+
return {
|
|
154
|
+
x: touch.clientX,
|
|
155
|
+
y: touch.clientY,
|
|
156
|
+
id: touch.identifier,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
var evt = e;
|
|
160
|
+
return {
|
|
161
|
+
x: evt.clientX,
|
|
162
|
+
y: evt.clientY,
|
|
163
|
+
id: null,
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Event on start dragging
|
|
168
|
+
*/
|
|
169
|
+
Dragger.prototype._handleStart = function (e) {
|
|
170
|
+
if (!this.prop.enabled) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (this.isDragging) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
var evt = this._normalizeEvent(e);
|
|
177
|
+
// prevent actions
|
|
178
|
+
if (e.type === 'mousedown') {
|
|
179
|
+
if (e.which === 1) {
|
|
180
|
+
e.stopPropagation();
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// update states
|
|
187
|
+
this._isDragging = true;
|
|
188
|
+
this._pointerID = evt.id;
|
|
189
|
+
// change coordinates
|
|
190
|
+
this._coords = { x: evt.x, y: evt.y };
|
|
191
|
+
this._prevCoords = { x: evt.x, y: evt.y };
|
|
192
|
+
this._startCoords = { x: evt.x, y: evt.y };
|
|
193
|
+
// add additional events
|
|
194
|
+
this._addRuntimeEvents();
|
|
195
|
+
// launch callbacks
|
|
196
|
+
this.callbacks.tbt('start', {
|
|
197
|
+
evt: e,
|
|
198
|
+
});
|
|
199
|
+
return true;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Event on drag end
|
|
203
|
+
*/
|
|
204
|
+
Dragger.prototype._handleEnd = function (e) {
|
|
205
|
+
var evt = this._normalizeEvent(e);
|
|
206
|
+
if (!this.isDragging || evt.id !== this._pointerID) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
this.cancel();
|
|
210
|
+
return true;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Cancel dragging
|
|
214
|
+
*/
|
|
215
|
+
Dragger.prototype.cancel = function () {
|
|
216
|
+
this._removeRuntimeEvents();
|
|
217
|
+
this._isDragging = false;
|
|
218
|
+
this.callbacks.tbt('end', false);
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Destroy the module
|
|
222
|
+
*/
|
|
223
|
+
Dragger.prototype._destroy = function () {
|
|
224
|
+
_super.prototype._destroy.call(this);
|
|
225
|
+
this._removeRuntimeEvents();
|
|
226
|
+
};
|
|
227
|
+
return Dragger;
|
|
228
|
+
}(Component_1.Component));
|
|
229
|
+
exports.Dragger = Dragger;
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DraggerDirection = void 0;
|
|
30
|
+
var Dragger_1 = require("./Dragger");
|
|
31
|
+
/**
|
|
32
|
+
* Dragger that detects direction
|
|
33
|
+
*/
|
|
34
|
+
var DraggerDirection = /** @class */ (function (_super) {
|
|
35
|
+
__extends(DraggerDirection, _super);
|
|
36
|
+
function DraggerDirection() {
|
|
37
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
38
|
+
}
|
|
39
|
+
DraggerDirection.prototype._getDefaultProp = function () {
|
|
40
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { min: 75 });
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Event on drag end
|
|
44
|
+
*/
|
|
45
|
+
DraggerDirection.prototype._handleEnd = function (e) {
|
|
46
|
+
var res = _super.prototype._handleEnd.call(this, e);
|
|
47
|
+
if (!res) {
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
var evt = this._normalizeEvent(e);
|
|
51
|
+
var startCoords = this.startCoords;
|
|
52
|
+
var min = Math.abs(this.prop.min);
|
|
53
|
+
// up
|
|
54
|
+
if (startCoords.y > evt.y
|
|
55
|
+
&& Math.abs(evt.y - startCoords.y) >= min) {
|
|
56
|
+
this.callbacks.tbt('up', false);
|
|
57
|
+
}
|
|
58
|
+
// down
|
|
59
|
+
if (startCoords.y < evt.y
|
|
60
|
+
&& Math.abs(evt.y - startCoords.y) >= min) {
|
|
61
|
+
this.callbacks.tbt('down', false);
|
|
62
|
+
}
|
|
63
|
+
// left
|
|
64
|
+
if (startCoords.x > evt.x
|
|
65
|
+
&& Math.abs(evt.x - startCoords.x) >= min) {
|
|
66
|
+
this.callbacks.tbt('left', false);
|
|
67
|
+
}
|
|
68
|
+
// right
|
|
69
|
+
if (startCoords.x < evt.x
|
|
70
|
+
&& Math.abs(evt.x - startCoords.x) >= min) {
|
|
71
|
+
this.callbacks.tbt('right', false);
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
return DraggerDirection;
|
|
76
|
+
}(Dragger_1.Dragger));
|
|
77
|
+
exports.DraggerDirection = DraggerDirection;
|