vevet 2.0.1-dev.2 → 2.0.1-dev.20
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/build/cdn/index.js +1 -1
- package/build/cjs/components/canvas/Ctx2DPrerender.js +20 -2
- package/build/cjs/components/loading/ProgressPreloader.js +14 -2
- package/build/cjs/components/page/Page.js +36 -8
- package/build/cjs/components/scroll/plugins/SmoothScrollDragPlugin.js +40 -5
- package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
- package/build/cjs/components/scroll/scrollable/ScrollView.js +67 -53
- package/build/cjs/components/scroll/scrollbar/Bar.js +8 -2
- package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +11 -3
- package/build/cjs/components/text/SplitText.js +18 -2
- package/build/cjs/components/timeline/Timeline.js +1 -0
- package/build/cjs/handlers/wheel/WheelHandler.js +195 -0
- package/build/cjs/index.js +3 -1
- package/build/cjs/utils/listeners/onScroll.js +65 -25
- package/build/cjs/utils/math/index.js +5 -1
- package/build/cjs/utils/math/spreadScopeProgress.js +18 -0
- package/build/cjs/utils/math/wrap.js +13 -0
- package/build/es/app/Application.js +50 -93
- package/build/es/app/events/PageLoad.js +3 -7
- package/build/es/app/events/Viewport.js +10 -34
- package/build/es/base/Callbacks.js +8 -19
- package/build/es/base/Component.js +0 -1
- package/build/es/base/Module.js +41 -61
- package/build/es/base/MutableProp.js +10 -32
- package/build/es/base/Plugin.js +0 -1
- package/build/es/components/animation-frame/AnimationFrame.js +4 -28
- package/build/es/components/canvas/Ctx2D.js +21 -49
- package/build/es/components/canvas/Ctx2DPrerender.js +21 -7
- package/build/es/components/cursor/CustomCursor.js +25 -58
- package/build/es/components/dragger/Dragger.js +20 -41
- package/build/es/components/dragger/DraggerDirection.js +1 -4
- package/build/es/components/loading/Preloader.js +26 -41
- package/build/es/components/loading/ProgressPreloader.js +31 -38
- package/build/es/components/page/Page.js +46 -41
- package/build/es/components/scroll/plugins/SmoothScrollDragPlugin.js +47 -29
- package/build/es/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
- package/build/es/components/scroll/scrollable/ScrollEventsBase.js +15 -22
- package/build/es/components/scroll/scrollable/ScrollView.js +62 -74
- package/build/es/components/scroll/scrollbar/Bar.js +43 -54
- package/build/es/components/scroll/scrollbar/ScrollBar.js +47 -73
- package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +63 -135
- package/build/es/components/text/SplitText.js +38 -43
- package/build/es/components/timeline/StaticTimeline.js +11 -22
- package/build/es/components/timeline/Timeline.js +13 -28
- package/build/es/handlers/wheel/WheelHandler.js +153 -0
- package/build/es/index.js +2 -1
- package/build/es/utils/listeners/onScroll.js +64 -25
- package/build/es/utils/math/index.js +3 -1
- package/build/es/utils/math/spreadScopeProgress.js +15 -0
- package/build/es/utils/math/wrap.js +10 -0
- package/build/types/components/canvas/Ctx2DPrerender.d.ts +1 -1
- package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -1
- package/build/types/components/loading/ProgressPreloader.d.ts +7 -0
- package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -1
- package/build/types/components/page/Page.d.ts +2 -0
- package/build/types/components/page/Page.d.ts.map +1 -1
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts +11 -0
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts.map +1 -1
- package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts.map +1 -1
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +27 -13
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
- package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
- package/build/types/components/text/SplitText.d.ts +6 -0
- package/build/types/components/text/SplitText.d.ts.map +1 -1
- package/build/types/components/timeline/Timeline.d.ts.map +1 -1
- package/build/types/handlers/wheel/WheelHandler.d.ts +100 -0
- package/build/types/handlers/wheel/WheelHandler.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/utils/listeners/onScroll.d.ts +13 -5
- package/build/types/utils/listeners/onScroll.d.ts.map +1 -1
- package/build/types/utils/math/index.d.ts +3 -1
- package/build/types/utils/math/index.d.ts.map +1 -1
- package/build/types/utils/math/spreadScopeProgress.d.ts +5 -0
- package/build/types/utils/math/spreadScopeProgress.d.ts.map +1 -0
- package/build/types/utils/math/wrap.d.ts +5 -0
- package/build/types/utils/math/wrap.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/sass/components/cursor/_custom-cursor.scss +0 -1
- package/src/ts/components/canvas/Ctx2DPrerender.ts +23 -6
- package/src/ts/components/loading/ProgressPreloader.ts +21 -2
- package/src/ts/components/page/Page.ts +34 -8
- package/src/ts/components/scroll/plugins/SmoothScrollDragPlugin.ts +58 -5
- package/src/ts/components/scroll/plugins/SmoothScrollKeyboardPlugin.ts +12 -0
- package/src/ts/components/scroll/scrollable/ScrollView.ts +78 -64
- package/src/ts/components/scroll/scrollbar/Bar.ts +8 -2
- package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +12 -3
- package/src/ts/components/text/SplitText.ts +26 -1
- package/src/ts/components/timeline/Timeline.ts +1 -0
- package/src/ts/handlers/wheel/WheelHandler.ts +269 -0
- package/src/ts/index.ts +4 -0
- package/src/ts/utils/listeners/onScroll.ts +105 -34
- package/src/ts/utils/math/index.ts +4 -0
- package/src/ts/utils/math/spreadScopeProgress.ts +18 -0
- package/src/ts/utils/math/wrap.ts +18 -0
|
@@ -0,0 +1,195 @@
|
|
|
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.WheelHandler = void 0;
|
|
33
|
+
var vevet_dom_1 = require("vevet-dom");
|
|
34
|
+
var normalize_wheel_1 = __importDefault(require("normalize-wheel"));
|
|
35
|
+
var Module_1 = require("../../base/Module");
|
|
36
|
+
/**
|
|
37
|
+
* Wheel events: up & down, left & right without repeating
|
|
38
|
+
|
|
39
|
+
*/
|
|
40
|
+
var WheelHandler = /** @class */ (function (_super) {
|
|
41
|
+
__extends(WheelHandler, _super);
|
|
42
|
+
function WheelHandler(initialProp, init) {
|
|
43
|
+
if (init === void 0) { init = true; }
|
|
44
|
+
var _this = _super.call(this, initialProp, false) || this;
|
|
45
|
+
_this._wheelListener = undefined;
|
|
46
|
+
_this._lockWheel = false;
|
|
47
|
+
if (init) {
|
|
48
|
+
_this.init();
|
|
49
|
+
}
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
WheelHandler.prototype._getDefaultProp = function () {
|
|
53
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: false, enabled: true, stopPropagation: false, threshold: 20 });
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(WheelHandler.prototype, "container", {
|
|
56
|
+
/**
|
|
57
|
+
* Listener contianer
|
|
58
|
+
*/
|
|
59
|
+
get: function () {
|
|
60
|
+
if (!this.prop.container) {
|
|
61
|
+
return window;
|
|
62
|
+
}
|
|
63
|
+
return this.prop.container;
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
// Set Module Events
|
|
69
|
+
WheelHandler.prototype._setEvents = function () {
|
|
70
|
+
_super.prototype._setEvents.call(this);
|
|
71
|
+
if (!(this.container instanceof Window)) {
|
|
72
|
+
this._listeners.push(vevet_dom_1.addEventListener(this.container, 'mouseenter', this._handleMouseEnter.bind(this)));
|
|
73
|
+
this._listeners.push(vevet_dom_1.addEventListener(this.container, 'mouseleave', this._handleMouseLeave.bind(this)));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this._toggleWheelEvent();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
WheelHandler.prototype._onPropMutate = function () {
|
|
80
|
+
_super.prototype._onPropMutate.call(this);
|
|
81
|
+
this._toggleWheelEvent();
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Handle element mouse enter
|
|
85
|
+
*/
|
|
86
|
+
WheelHandler.prototype._handleMouseEnter = function () {
|
|
87
|
+
if (this.prop.enabled) {
|
|
88
|
+
this._createWheelEvent();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Handle element mouse leave
|
|
93
|
+
*/
|
|
94
|
+
WheelHandler.prototype._handleMouseLeave = function () {
|
|
95
|
+
this._destroyWheelEvent();
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Set wheel event
|
|
99
|
+
*/
|
|
100
|
+
WheelHandler.prototype._toggleWheelEvent = function () {
|
|
101
|
+
if (this.prop.enabled) {
|
|
102
|
+
this._createWheelEvent();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this._destroyWheelEvent();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Create a wheel event
|
|
110
|
+
*/
|
|
111
|
+
WheelHandler.prototype._createWheelEvent = function () {
|
|
112
|
+
if (this._wheelListener) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// reset gaining
|
|
116
|
+
this._lockWheel = false;
|
|
117
|
+
if (this._lockWheelTimeout) {
|
|
118
|
+
clearTimeout(this._lockWheelTimeout);
|
|
119
|
+
}
|
|
120
|
+
// create a listener
|
|
121
|
+
this._wheelListener = vevet_dom_1.addEventListener(this.container, 'wheel',
|
|
122
|
+
// throttle(this._handleWheel.bind(this), 200),
|
|
123
|
+
this._handleWheel.bind(this));
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Destroy the wheel event
|
|
127
|
+
*/
|
|
128
|
+
WheelHandler.prototype._destroyWheelEvent = function () {
|
|
129
|
+
if (!this._wheelListener) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this._wheelListener.remove();
|
|
133
|
+
this._wheelListener = undefined;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Handle wheel event
|
|
137
|
+
*/
|
|
138
|
+
WheelHandler.prototype._handleWheel = function (evt) {
|
|
139
|
+
var _this = this;
|
|
140
|
+
if (!this._wheelListener) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// stop propagation
|
|
144
|
+
if (this.prop.stopPropagation) {
|
|
145
|
+
evt.preventDefault();
|
|
146
|
+
evt.stopPropagation();
|
|
147
|
+
}
|
|
148
|
+
// if locked
|
|
149
|
+
if (this._lockWheel) {
|
|
150
|
+
if (this._lockWheelTimeout) {
|
|
151
|
+
clearTimeout(this._lockWheelTimeout);
|
|
152
|
+
}
|
|
153
|
+
this._lockWheelTimeout = setTimeout(function () {
|
|
154
|
+
_this._lockWheel = false;
|
|
155
|
+
}, 300);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// data
|
|
159
|
+
var delta = normalize_wheel_1.default(evt);
|
|
160
|
+
var threshold = this.prop.threshold;
|
|
161
|
+
// launch events
|
|
162
|
+
var eventFired = false;
|
|
163
|
+
// Y
|
|
164
|
+
if (delta.pixelY > threshold) {
|
|
165
|
+
this._callbacks.tbt('down', false);
|
|
166
|
+
eventFired = true;
|
|
167
|
+
}
|
|
168
|
+
else if (delta.pixelY < threshold * -1) {
|
|
169
|
+
this._callbacks.tbt('up', false);
|
|
170
|
+
eventFired = true;
|
|
171
|
+
}
|
|
172
|
+
// X
|
|
173
|
+
if (delta.pixelX > threshold) {
|
|
174
|
+
this._callbacks.tbt('right', false);
|
|
175
|
+
eventFired = true;
|
|
176
|
+
}
|
|
177
|
+
else if (delta.pixelX < threshold * -1) {
|
|
178
|
+
this._callbacks.tbt('left', false);
|
|
179
|
+
eventFired = true;
|
|
180
|
+
}
|
|
181
|
+
// lock events
|
|
182
|
+
if (eventFired) {
|
|
183
|
+
this._lockWheel = true;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Destroy the module
|
|
188
|
+
*/
|
|
189
|
+
WheelHandler.prototype._destroy = function () {
|
|
190
|
+
_super.prototype._destroy.call(this);
|
|
191
|
+
this._destroyWheelEvent();
|
|
192
|
+
};
|
|
193
|
+
return WheelHandler;
|
|
194
|
+
}(Module_1.Module));
|
|
195
|
+
exports.WheelHandler = WheelHandler;
|
package/build/cjs/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.CustomCursor = exports.SplitText = exports.SmoothScrollDragPlugin = exports.SmoothScrollKeyboardPlugin = exports.ScrollView = exports.ScrollEventsBase = exports.ScrollBar = exports.SmoothScroll = exports.Ctx2DPrerender = exports.Ctx2D = exports.DraggerDirection = exports.DraggerMove = exports.Dragger = exports.ProgressPreloader = exports.Preloader = exports.Timeline = exports.StaticTimeline = exports.AnimationFrame = exports.Page = exports.Plugin = exports.Component = exports.Module = exports.MutableProp = exports.Callbacks = exports.PageLoad = exports.Viewport = exports.Application = exports.GeneralTypes = exports.utils = void 0;
|
|
22
|
+
exports.CustomCursor = exports.SplitText = exports.SmoothScrollDragPlugin = exports.SmoothScrollKeyboardPlugin = exports.ScrollView = exports.ScrollEventsBase = exports.ScrollBar = exports.SmoothScroll = exports.Ctx2DPrerender = exports.Ctx2D = exports.DraggerDirection = exports.DraggerMove = exports.Dragger = exports.ProgressPreloader = exports.Preloader = exports.Timeline = exports.StaticTimeline = exports.AnimationFrame = exports.WheelHandler = exports.Page = exports.Plugin = exports.Component = exports.Module = exports.MutableProp = exports.Callbacks = exports.PageLoad = exports.Viewport = exports.Application = exports.GeneralTypes = exports.utils = void 0;
|
|
23
23
|
var common = __importStar(require("./utils/common"));
|
|
24
24
|
var listeners = __importStar(require("./utils/listeners"));
|
|
25
25
|
var math = __importStar(require("./utils/math"));
|
|
@@ -43,6 +43,8 @@ var Plugin_1 = require("./base/Plugin");
|
|
|
43
43
|
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return Plugin_1.Plugin; } });
|
|
44
44
|
var Page_1 = require("./components/page/Page");
|
|
45
45
|
Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return Page_1.Page; } });
|
|
46
|
+
var WheelHandler_1 = require("./handlers/wheel/WheelHandler");
|
|
47
|
+
Object.defineProperty(exports, "WheelHandler", { enumerable: true, get: function () { return WheelHandler_1.WheelHandler; } });
|
|
46
48
|
var AnimationFrame_1 = require("./components/animation-frame/AnimationFrame");
|
|
47
49
|
Object.defineProperty(exports, "AnimationFrame", { enumerable: true, get: function () { return AnimationFrame_1.AnimationFrame; } });
|
|
48
50
|
var StaticTimeline_1 = require("./components/timeline/StaticTimeline");
|
|
@@ -2,45 +2,85 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var vevet_dom_1 = require("vevet-dom");
|
|
4
4
|
var SmoothScroll_1 = require("../../components/scroll/smooth-scroll/SmoothScroll");
|
|
5
|
+
var common_1 = require("../common");
|
|
6
|
+
var instances = [];
|
|
5
7
|
/**
|
|
6
8
|
* Add OnScroll event
|
|
7
9
|
*/
|
|
8
|
-
function onScroll(
|
|
9
|
-
var
|
|
10
|
-
if
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
function onScroll(_a) {
|
|
11
|
+
var container = _a.container, callback = _a.callback, _b = _a.isPassive, isPassive = _b === void 0 ? false : _b;
|
|
12
|
+
// check if listeners for this element already exist
|
|
13
|
+
var instance = instances.find(function (data) { return (data.container === container && data.isPassive === isPassive); });
|
|
14
|
+
var callbackId = common_1.randID('scroll-event');
|
|
15
|
+
// if a listener exists, we just add a new callback to its stack
|
|
16
|
+
if (instance) {
|
|
17
|
+
instance.callbacks.push({
|
|
18
|
+
id: callbackId,
|
|
19
|
+
callback: callback,
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
// otherwise we create a new instance
|
|
24
|
+
instance = {
|
|
25
|
+
id: common_1.randID('scroll-event-instance'),
|
|
26
|
+
container: container,
|
|
27
|
+
callbacks: [{
|
|
28
|
+
id: callbackId,
|
|
29
|
+
callback: callback,
|
|
30
|
+
}],
|
|
31
|
+
isPassive: isPassive,
|
|
32
|
+
listeners: [],
|
|
33
|
+
};
|
|
34
|
+
instances.push(instance);
|
|
35
|
+
// vars
|
|
36
|
+
var listeners = instance.listeners;
|
|
37
|
+
// smooth scroll events
|
|
38
|
+
if (container instanceof SmoothScroll_1.SmoothScroll) {
|
|
39
|
+
listeners.push(container.addCallback('scroll', function () {
|
|
40
|
+
var scrollTop = container.scrollTop, scrollLeft = container.scrollLeft;
|
|
41
|
+
for (var index = 0; index < instance.callbacks.length; index += 1) {
|
|
42
|
+
instance.callbacks[index].callback({
|
|
43
|
+
scrollTop: scrollTop,
|
|
44
|
+
scrollLeft: scrollLeft,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
22
48
|
}
|
|
23
49
|
else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
listeners.push(vevet_dom_1.addEventListener(
|
|
28
|
-
var scrollTop =
|
|
29
|
-
?
|
|
30
|
-
var scrollLeft =
|
|
31
|
-
?
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
// dom scroll events
|
|
51
|
+
var isWindow_1 = container instanceof Window;
|
|
52
|
+
var domContainer_1 = vevet_dom_1.selectOne(container);
|
|
53
|
+
listeners.push(vevet_dom_1.addEventListener(domContainer_1, 'scroll', function () {
|
|
54
|
+
var scrollTop = isWindow_1
|
|
55
|
+
? domContainer_1.pageYOffset : domContainer_1.scrollTop;
|
|
56
|
+
var scrollLeft = isWindow_1
|
|
57
|
+
? domContainer_1.pageXOffset : domContainer_1.scrollLeft;
|
|
58
|
+
for (var index = 0; index < instance.callbacks.length; index += 1) {
|
|
59
|
+
instance.callbacks[index].callback({
|
|
60
|
+
scrollTop: scrollTop,
|
|
61
|
+
scrollLeft: scrollLeft,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
passive: isPassive,
|
|
36
66
|
}));
|
|
37
67
|
}
|
|
38
68
|
}
|
|
39
69
|
return {
|
|
40
70
|
remove: function () {
|
|
41
|
-
|
|
42
|
-
|
|
71
|
+
var newCallbacks = instance.callbacks.filter(function (item) {
|
|
72
|
+
if (item.id !== callbackId) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
43
76
|
});
|
|
77
|
+
instance.callbacks = newCallbacks;
|
|
78
|
+
if (newCallbacks.length === 0) {
|
|
79
|
+
instance.listeners.forEach(function (listener) {
|
|
80
|
+
listener.remove();
|
|
81
|
+
});
|
|
82
|
+
instances = instances.filter(function (item) { return item.id !== instance.id; });
|
|
83
|
+
}
|
|
44
84
|
},
|
|
45
85
|
};
|
|
46
86
|
}
|
|
@@ -3,10 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.scopeProgress = exports.lerp = exports.boundVal = void 0;
|
|
6
|
+
exports.wrap = exports.spreadScopeProgress = exports.scopeProgress = exports.lerp = exports.boundVal = void 0;
|
|
7
7
|
var boundVal_1 = __importDefault(require("./boundVal"));
|
|
8
8
|
exports.boundVal = boundVal_1.default;
|
|
9
9
|
var lerp_1 = __importDefault(require("./lerp"));
|
|
10
10
|
exports.lerp = lerp_1.default;
|
|
11
11
|
var scopeProgress_1 = __importDefault(require("./scopeProgress"));
|
|
12
12
|
exports.scopeProgress = scopeProgress_1.default;
|
|
13
|
+
var spreadScopeProgress_1 = __importDefault(require("./spreadScopeProgress"));
|
|
14
|
+
exports.spreadScopeProgress = spreadScopeProgress_1.default;
|
|
15
|
+
var wrap_1 = __importDefault(require("./wrap"));
|
|
16
|
+
exports.wrap = wrap_1.default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Distribute scope progress among a certain quantity of timelines.
|
|
5
|
+
*/
|
|
6
|
+
function spreadScopeProgress(quantity, shift) {
|
|
7
|
+
var timelines = [];
|
|
8
|
+
// duration for each element
|
|
9
|
+
var duration = 1 / (quantity - shift * (quantity - 1));
|
|
10
|
+
// calculate timelines
|
|
11
|
+
for (var index = 0; index < quantity; index += 1) {
|
|
12
|
+
var start = (duration * (1 - shift)) * index;
|
|
13
|
+
var end = start + duration;
|
|
14
|
+
timelines.push([start, end]);
|
|
15
|
+
}
|
|
16
|
+
return timelines;
|
|
17
|
+
}
|
|
18
|
+
exports.default = spreadScopeProgress;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Wrap values
|
|
5
|
+
*/
|
|
6
|
+
function wrap(min, max, value) {
|
|
7
|
+
var range = max - min;
|
|
8
|
+
return conditionalReturn(value, function (val) { return ((range + ((val - min) % range)) % range) + min; });
|
|
9
|
+
}
|
|
10
|
+
exports.default = wrap;
|
|
11
|
+
function conditionalReturn(value, func) {
|
|
12
|
+
return value || value === 0 ? func(value) : func;
|
|
13
|
+
}
|
|
@@ -7,77 +7,6 @@ import { PageLoad } from './events/PageLoad';
|
|
|
7
7
|
* Vevet Application
|
|
8
8
|
*/
|
|
9
9
|
export class Application {
|
|
10
|
-
/**
|
|
11
|
-
* Application properties.
|
|
12
|
-
*/
|
|
13
|
-
_prop;
|
|
14
|
-
/**
|
|
15
|
-
* Application properties.
|
|
16
|
-
*/
|
|
17
|
-
get prop() {
|
|
18
|
-
return this._prop;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Default properties.
|
|
22
|
-
*/
|
|
23
|
-
get defaultProp() {
|
|
24
|
-
return {
|
|
25
|
-
tablet: 1199,
|
|
26
|
-
phone: 899,
|
|
27
|
-
prefix: 'v-',
|
|
28
|
-
easing: [0.25, 0.1, 0.25, 1],
|
|
29
|
-
viewportResizeTimeout: 0,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Vevet prefix.
|
|
34
|
-
*/
|
|
35
|
-
_prefix;
|
|
36
|
-
get prefix() {
|
|
37
|
-
return this._prefix;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* If is phone
|
|
41
|
-
*/
|
|
42
|
-
_isPhone;
|
|
43
|
-
get isPhone() {
|
|
44
|
-
return this._isPhone;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* If tablet
|
|
48
|
-
*/
|
|
49
|
-
_isTablet;
|
|
50
|
-
get isTablet() {
|
|
51
|
-
return this._isTablet;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* If mobile device
|
|
55
|
-
*/
|
|
56
|
-
_isMobile;
|
|
57
|
-
get isMobile() {
|
|
58
|
-
return this._isMobile;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* If desktop device
|
|
62
|
-
*/
|
|
63
|
-
_isDesktop;
|
|
64
|
-
get isDesktop() {
|
|
65
|
-
return this._isDesktop;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* OS name
|
|
69
|
-
*/
|
|
70
|
-
_osName;
|
|
71
|
-
get osName() {
|
|
72
|
-
return this._osName;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* OS name
|
|
76
|
-
*/
|
|
77
|
-
_browserName;
|
|
78
|
-
get browserName() {
|
|
79
|
-
return this._browserName;
|
|
80
|
-
}
|
|
81
10
|
/**
|
|
82
11
|
* @example
|
|
83
12
|
* const app = Application({
|
|
@@ -85,15 +14,20 @@ export class Application {
|
|
|
85
14
|
* });
|
|
86
15
|
*/
|
|
87
16
|
constructor(data = {}) {
|
|
17
|
+
/**
|
|
18
|
+
* Pages (instances)
|
|
19
|
+
*/
|
|
20
|
+
this._pages = [];
|
|
21
|
+
/**
|
|
22
|
+
* Current Page (instance).
|
|
23
|
+
*/
|
|
24
|
+
this._page = false;
|
|
88
25
|
// check if the application already exists
|
|
89
26
|
if (window.vevetApp) {
|
|
90
27
|
throw new Error('Vevet Application already exists!');
|
|
91
28
|
}
|
|
92
29
|
// set defaults
|
|
93
|
-
this._prop = {
|
|
94
|
-
...this.defaultProp,
|
|
95
|
-
...data,
|
|
96
|
-
};
|
|
30
|
+
this._prop = Object.assign(Object.assign({}, this.defaultProp), data);
|
|
97
31
|
this._prefix = this.prop.prefix;
|
|
98
32
|
// initialize the application
|
|
99
33
|
// Define that you're using Vevet
|
|
@@ -113,7 +47,7 @@ export class Application {
|
|
|
113
47
|
// get browser info
|
|
114
48
|
const browserData = detect();
|
|
115
49
|
// get OS name
|
|
116
|
-
if (browserData
|
|
50
|
+
if (browserData === null || browserData === void 0 ? void 0 : browserData.os) {
|
|
117
51
|
const osName = browserData.os.split(' ')[0].toLowerCase();
|
|
118
52
|
this.html.classList.add(`${this.prefix}os-${osName}`);
|
|
119
53
|
this._osName = osName;
|
|
@@ -122,7 +56,7 @@ export class Application {
|
|
|
122
56
|
this._osName = '';
|
|
123
57
|
}
|
|
124
58
|
// get browser name
|
|
125
|
-
if (browserData
|
|
59
|
+
if (browserData === null || browserData === void 0 ? void 0 : browserData.name) {
|
|
126
60
|
const browserName = browserData.name.toLowerCase();
|
|
127
61
|
this.html.classList.add(`${this.prefix}browser-${browserName}`);
|
|
128
62
|
this._browserName = browserName;
|
|
@@ -135,6 +69,45 @@ export class Application {
|
|
|
135
69
|
this._pageLoad = new PageLoad();
|
|
136
70
|
this._viewport = new Viewport();
|
|
137
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Application properties.
|
|
74
|
+
*/
|
|
75
|
+
get prop() {
|
|
76
|
+
return this._prop;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Default properties.
|
|
80
|
+
*/
|
|
81
|
+
get defaultProp() {
|
|
82
|
+
return {
|
|
83
|
+
tablet: 1199,
|
|
84
|
+
phone: 899,
|
|
85
|
+
prefix: 'v-',
|
|
86
|
+
easing: [0.25, 0.1, 0.25, 1],
|
|
87
|
+
viewportResizeTimeout: 0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
get prefix() {
|
|
91
|
+
return this._prefix;
|
|
92
|
+
}
|
|
93
|
+
get isPhone() {
|
|
94
|
+
return this._isPhone;
|
|
95
|
+
}
|
|
96
|
+
get isTablet() {
|
|
97
|
+
return this._isTablet;
|
|
98
|
+
}
|
|
99
|
+
get isMobile() {
|
|
100
|
+
return this._isMobile;
|
|
101
|
+
}
|
|
102
|
+
get isDesktop() {
|
|
103
|
+
return this._isDesktop;
|
|
104
|
+
}
|
|
105
|
+
get osName() {
|
|
106
|
+
return this._osName;
|
|
107
|
+
}
|
|
108
|
+
get browserName() {
|
|
109
|
+
return this._browserName;
|
|
110
|
+
}
|
|
138
111
|
/**
|
|
139
112
|
* Get document element.
|
|
140
113
|
*/
|
|
@@ -153,10 +126,6 @@ export class Application {
|
|
|
153
126
|
get body() {
|
|
154
127
|
return document.body;
|
|
155
128
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Pages (instances)
|
|
158
|
-
*/
|
|
159
|
-
_pages = [];
|
|
160
129
|
/**
|
|
161
130
|
* Get an array of existing pages.
|
|
162
131
|
* A new element is added to the array when {@linkcode Vevet.Page.create} is called.
|
|
@@ -164,10 +133,6 @@ export class Application {
|
|
|
164
133
|
get pages() {
|
|
165
134
|
return this._pages;
|
|
166
135
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Current Page (instance).
|
|
169
|
-
*/
|
|
170
|
-
_page = false;
|
|
171
136
|
/**
|
|
172
137
|
* Get the current page instance.
|
|
173
138
|
*/
|
|
@@ -212,10 +177,6 @@ export class Application {
|
|
|
212
177
|
});
|
|
213
178
|
});
|
|
214
179
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Page Load Callbacks
|
|
217
|
-
*/
|
|
218
|
-
_pageLoad;
|
|
219
180
|
get pageLoad() {
|
|
220
181
|
return this._pageLoad;
|
|
221
182
|
}
|
|
@@ -229,10 +190,6 @@ export class Application {
|
|
|
229
190
|
});
|
|
230
191
|
});
|
|
231
192
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Viewport Callbacks
|
|
234
|
-
*/
|
|
235
|
-
_viewport;
|
|
236
193
|
get viewport() {
|
|
237
194
|
return this._viewport;
|
|
238
195
|
}
|
|
@@ -3,18 +3,14 @@ import { Callbacks } from '../../base/Callbacks';
|
|
|
3
3
|
* Callbacks on page loaded.
|
|
4
4
|
*/
|
|
5
5
|
export class PageLoad extends Callbacks {
|
|
6
|
-
/**
|
|
7
|
-
* If the page is loaded.
|
|
8
|
-
*/
|
|
9
|
-
_loaded;
|
|
10
|
-
get loaded() {
|
|
11
|
-
return this._loaded;
|
|
12
|
-
}
|
|
13
6
|
constructor() {
|
|
14
7
|
super(false);
|
|
15
8
|
this._loaded = false;
|
|
16
9
|
this._init();
|
|
17
10
|
}
|
|
11
|
+
get loaded() {
|
|
12
|
+
return this._loaded;
|
|
13
|
+
}
|
|
18
14
|
_setEvents() {
|
|
19
15
|
if (document.readyState === 'complete') {
|
|
20
16
|
this._handleLoaded();
|
|
@@ -22,17 +22,19 @@ var OrientationTypes;
|
|
|
22
22
|
* Here the names of the OS, Browser, and Device are also available. <br>
|
|
23
23
|
*/
|
|
24
24
|
export class Viewport extends Callbacks {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
constructor() {
|
|
26
|
+
super(false);
|
|
27
|
+
this._width = 0;
|
|
28
|
+
this._height = 0;
|
|
29
|
+
this._prevSize = { w: 0, h: 0 };
|
|
30
|
+
this._isDesktop = false;
|
|
31
|
+
this._isTablet = false;
|
|
32
|
+
this._isPhone = false;
|
|
33
|
+
this._init();
|
|
34
|
+
}
|
|
29
35
|
get width() {
|
|
30
36
|
return this._width;
|
|
31
37
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Current Viewport height
|
|
34
|
-
*/
|
|
35
|
-
_height;
|
|
36
38
|
get height() {
|
|
37
39
|
return this._height;
|
|
38
40
|
}
|
|
@@ -48,10 +50,6 @@ export class Viewport extends Callbacks {
|
|
|
48
50
|
get vh() {
|
|
49
51
|
return this.height / 100;
|
|
50
52
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Previous Viewport size
|
|
53
|
-
*/
|
|
54
|
-
_prevSize;
|
|
55
53
|
/**
|
|
56
54
|
* Get previous Viewport size
|
|
57
55
|
*/
|
|
@@ -70,24 +68,12 @@ export class Viewport extends Callbacks {
|
|
|
70
68
|
get isPortrait() {
|
|
71
69
|
return this.width < this.height;
|
|
72
70
|
}
|
|
73
|
-
/**
|
|
74
|
-
* If desktop size
|
|
75
|
-
*/
|
|
76
|
-
_isDesktop;
|
|
77
71
|
get isDesktop() {
|
|
78
72
|
return this._isDesktop;
|
|
79
73
|
}
|
|
80
|
-
/**
|
|
81
|
-
* If tablet size
|
|
82
|
-
*/
|
|
83
|
-
_isTablet;
|
|
84
74
|
get isTablet() {
|
|
85
75
|
return this._isTablet;
|
|
86
76
|
}
|
|
87
|
-
/**
|
|
88
|
-
* If phone size
|
|
89
|
-
*/
|
|
90
|
-
_isPhone;
|
|
91
77
|
get isPhone() {
|
|
92
78
|
return this._isPhone;
|
|
93
79
|
}
|
|
@@ -109,16 +95,6 @@ export class Viewport extends Callbacks {
|
|
|
109
95
|
}
|
|
110
96
|
return this.dpr;
|
|
111
97
|
}
|
|
112
|
-
constructor() {
|
|
113
|
-
super(false);
|
|
114
|
-
this._width = 0;
|
|
115
|
-
this._height = 0;
|
|
116
|
-
this._prevSize = { w: 0, h: 0 };
|
|
117
|
-
this._isDesktop = false;
|
|
118
|
-
this._isTablet = false;
|
|
119
|
-
this._isPhone = false;
|
|
120
|
-
this._init();
|
|
121
|
-
}
|
|
122
98
|
// Extra constructor
|
|
123
99
|
_constructor() {
|
|
124
100
|
super._constructor();
|