vevet 3.0.0-beta.1 → 3.0.0-beta.2
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/lib/cjs/Application/events/Viewport/index.js +1 -1
- package/lib/cjs/Application/events/Viewport/index.js.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/Application/events/PageLoad/index.js +54 -28
- package/lib/esm/Application/events/PageLoad/index.js.map +1 -1
- package/lib/esm/Application/events/Viewport/index.js +180 -107
- package/lib/esm/Application/events/Viewport/index.js.map +1 -1
- package/lib/esm/Application/index.js +178 -96
- package/lib/esm/Application/index.js.map +1 -1
- package/lib/esm/base/Callbacks/index.js +78 -45
- package/lib/esm/base/Callbacks/index.js.map +1 -1
- package/lib/esm/base/Component/index.js +31 -10
- package/lib/esm/base/Component/index.js.map +1 -1
- package/lib/esm/base/Module/index.js +132 -77
- package/lib/esm/base/Module/index.js.map +1 -1
- package/lib/esm/base/MutableProps/index.js +49 -30
- package/lib/esm/base/MutableProps/index.js.map +1 -1
- package/lib/esm/base/Plugin/index.js +35 -13
- package/lib/esm/base/Plugin/index.js.map +1 -1
- package/lib/esm/components/AnimationFrame/index.js +98 -55
- package/lib/esm/components/AnimationFrame/index.js.map +1 -1
- package/lib/esm/components/BaseTimeline/index.js +88 -41
- package/lib/esm/components/BaseTimeline/index.js.map +1 -1
- package/lib/esm/components/Ctx2D/index.js +150 -82
- package/lib/esm/components/Ctx2D/index.js.map +1 -1
- package/lib/esm/components/Ctx2DPrerender/index.js +54 -20
- package/lib/esm/components/Ctx2DPrerender/index.js.map +1 -1
- package/lib/esm/components/CustomCursor/index.js +216 -149
- package/lib/esm/components/CustomCursor/index.js.map +1 -1
- package/lib/esm/components/DraggerBase/index.js +164 -98
- package/lib/esm/components/DraggerBase/index.js.map +1 -1
- package/lib/esm/components/DraggerDirection/index.js +42 -10
- package/lib/esm/components/DraggerDirection/index.js.map +1 -1
- package/lib/esm/components/DraggerMove/index.js +83 -42
- package/lib/esm/components/DraggerMove/index.js.map +1 -1
- package/lib/esm/components/Preloader/index.js +135 -77
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +190 -112
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js +10 -9
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js +3 -3
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js +2 -2
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js.map +1 -1
- package/lib/esm/components/ScrollBar/Bar/index.js +136 -90
- package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/esm/components/ScrollBar/index.js +118 -70
- package/lib/esm/components/ScrollBar/index.js.map +1 -1
- package/lib/esm/components/ScrollView/index.js +154 -103
- package/lib/esm/components/ScrollView/index.js.map +1 -1
- package/lib/esm/components/SectionScrollProgress/index.js +170 -95
- package/lib/esm/components/SectionScrollProgress/index.js.map +1 -1
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js +37 -20
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js.map +1 -1
- package/lib/esm/components/SmoothScroll/Elements.js +59 -42
- package/lib/esm/components/SmoothScroll/Elements.js.map +1 -1
- package/lib/esm/components/SmoothScroll/index.js +304 -205
- package/lib/esm/components/SmoothScroll/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollDragPlugin/index.js +86 -48
- package/lib/esm/components/SmoothScrollDragPlugin/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js +70 -34
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js +177 -117
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/Timeline/index.js +88 -45
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js.map +1 -1
- package/lib/esm/utils/common/normalizedTimeoutCallback.js +3 -3
- package/lib/esm/utils/common/normalizedTimeoutCallback.js.map +1 -1
- package/lib/esm/utils/common/pickObjectProps.js +2 -2
- package/lib/esm/utils/common/pickObjectProps.js.map +1 -1
- package/lib/esm/utils/common/times.js +2 -2
- package/lib/esm/utils/common/times.js.map +1 -1
- package/lib/esm/utils/common/uid.js +4 -3
- package/lib/esm/utils/common/uid.js.map +1 -1
- package/lib/esm/utils/image/load.js +26 -15
- package/lib/esm/utils/image/load.js.map +1 -1
- package/lib/esm/utils/image/pathsToProps.js +5 -5
- package/lib/esm/utils/image/pathsToProps.js.map +1 -1
- package/lib/esm/utils/image/sizesToSrcSet.js +5 -5
- package/lib/esm/utils/image/sizesToSrcSet.js.map +1 -1
- package/lib/esm/utils/internal/fetchWebpSupport.js +3 -3
- package/lib/esm/utils/internal/fetchWebpSupport.js.map +1 -1
- package/lib/esm/utils/internal/getDeviceInfo.js +7 -7
- package/lib/esm/utils/internal/getDeviceInfo.js.map +1 -1
- package/lib/esm/utils/internal/onResize.js +16 -13
- package/lib/esm/utils/internal/onResize.js.map +1 -1
- package/lib/esm/utils/math/clamp.js +2 -1
- package/lib/esm/utils/math/clamp.js.map +1 -1
- package/lib/esm/utils/math/clampScope.js +3 -1
- package/lib/esm/utils/math/clampScope.js.map +1 -1
- package/lib/esm/utils/math/easing.js +5 -1
- package/lib/esm/utils/math/easing.js.map +1 -1
- package/lib/esm/utils/math/inScope.js +2 -1
- package/lib/esm/utils/math/inScope.js.map +1 -1
- package/lib/esm/utils/math/lerp.js +4 -3
- package/lib/esm/utils/math/lerp.js.map +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js.map +1 -1
- package/lib/esm/utils/math/scoped.js +3 -2
- package/lib/esm/utils/math/scoped.js.map +1 -1
- package/lib/esm/utils/math/spreadScope.js +5 -5
- package/lib/esm/utils/math/spreadScope.js.map +1 -1
- package/lib/esm/utils/math/wrap.js +2 -2
- package/lib/esm/utils/math/wrap.js.map +1 -1
- package/lib/esm/utils/scroll/getScrollValues.js +6 -5
- package/lib/esm/utils/scroll/getScrollValues.js.map +1 -1
- package/lib/esm/utils/scroll/onScroll.js +23 -20
- package/lib/esm/utils/scroll/onScroll.js.map +1 -1
- package/lib/esm/utils/scroll/scrollTo.js +12 -10
- package/lib/esm/utils/scroll/scrollTo.js.map +1 -1
- package/lib/esm/utils/scroll/scrollToElement.js +19 -8
- package/lib/esm/utils/scroll/scrollToElement.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/vevet.js +1 -1
- package/lib/esm/vevet.js.map +1 -1
- package/lib/types/Application/events/Viewport/index.d.ts +1 -1
- package/lib/types/Application/events/Viewport/index.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Application/events/Viewport/index.ts +1 -1
- package/src/Application/events/Viewport/stories/index.tsx +1 -1
- package/src/version.ts +1 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import PCancelable from 'p-cancelable';
|
|
2
13
|
import { Viewport } from './events/Viewport';
|
|
3
14
|
import { PageLoad } from './events/PageLoad';
|
|
@@ -7,78 +18,19 @@ import { fetchWebpSupport } from '../utils/internal/fetchWebpSupport';
|
|
|
7
18
|
/**
|
|
8
19
|
* Vevet Application
|
|
9
20
|
*/
|
|
10
|
-
|
|
11
|
-
/** Vevet version */
|
|
12
|
-
get version() {
|
|
13
|
-
return version;
|
|
14
|
-
}
|
|
15
|
-
/** Application properties */
|
|
16
|
-
get props() {
|
|
17
|
-
return this._props;
|
|
18
|
-
}
|
|
19
|
-
/** Default properties */
|
|
20
|
-
get defaultProps() {
|
|
21
|
-
return {
|
|
22
|
-
isVersionPrinted: true,
|
|
23
|
-
tablet: 1199,
|
|
24
|
-
phone: 899,
|
|
25
|
-
prefix: 'v-',
|
|
26
|
-
easing: [0.25, 0.1, 0.25, 1],
|
|
27
|
-
resizeDebounce: 16,
|
|
28
|
-
hasWebpSupportCheck: true,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/** Vevet prefix */
|
|
32
|
-
get prefix() {
|
|
33
|
-
return this._props.prefix;
|
|
34
|
-
}
|
|
35
|
-
/** Is phone device */
|
|
36
|
-
get isPhone() {
|
|
37
|
-
return this._isPhone;
|
|
38
|
-
}
|
|
39
|
-
/** Is tablet device */
|
|
40
|
-
get isTablet() {
|
|
41
|
-
return this._isTablet;
|
|
42
|
-
}
|
|
43
|
-
/** Is phone device */
|
|
44
|
-
get isMobile() {
|
|
45
|
-
return this._isMobile;
|
|
46
|
-
}
|
|
47
|
-
/** Is desktop device */
|
|
48
|
-
get isDesktop() {
|
|
49
|
-
return this._isDesktop;
|
|
50
|
-
}
|
|
51
|
-
/** Operating system name */
|
|
52
|
-
get osName() {
|
|
53
|
-
return this._osName;
|
|
54
|
-
}
|
|
55
|
-
/** Browser name */
|
|
56
|
-
get browserName() {
|
|
57
|
-
return this._browserName;
|
|
58
|
-
}
|
|
59
|
-
/** WebP supported */
|
|
60
|
-
get isWebpSupported() {
|
|
61
|
-
return this._isWebpSupported;
|
|
62
|
-
}
|
|
63
|
-
/** Page Load Callbacks */
|
|
64
|
-
get pageLoad() {
|
|
65
|
-
return this._pageLoad;
|
|
66
|
-
}
|
|
67
|
-
/** Viewport Callbacks */
|
|
68
|
-
get viewport() {
|
|
69
|
-
return this._viewport;
|
|
70
|
-
}
|
|
21
|
+
var Application = /** @class */ (function () {
|
|
71
22
|
/**
|
|
72
23
|
* @example
|
|
73
24
|
* const app = Application();
|
|
74
25
|
*/
|
|
75
|
-
|
|
26
|
+
function Application(data) {
|
|
27
|
+
if (data === void 0) { data = {}; }
|
|
76
28
|
// check if the application already exists
|
|
77
29
|
if (window.vevetApp) {
|
|
78
30
|
throw new Error('Vevet Application already exists!');
|
|
79
31
|
}
|
|
80
32
|
// set defaults
|
|
81
|
-
this._props =
|
|
33
|
+
this._props = __assign(__assign({}, this.defaultProps), data);
|
|
82
34
|
this._isWebpSupported = false;
|
|
83
35
|
// initialize the application
|
|
84
36
|
// Define that you're using Vevet
|
|
@@ -90,54 +42,182 @@ export class Application {
|
|
|
90
42
|
this._pageLoad = new PageLoad();
|
|
91
43
|
this._viewport = new Viewport();
|
|
92
44
|
}
|
|
45
|
+
Object.defineProperty(Application.prototype, "version", {
|
|
46
|
+
/** Vevet version */
|
|
47
|
+
get: function () {
|
|
48
|
+
return version;
|
|
49
|
+
},
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(Application.prototype, "props", {
|
|
54
|
+
/** Application properties */
|
|
55
|
+
get: function () {
|
|
56
|
+
return this._props;
|
|
57
|
+
},
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(Application.prototype, "defaultProps", {
|
|
62
|
+
/** Default properties */
|
|
63
|
+
get: function () {
|
|
64
|
+
return {
|
|
65
|
+
isVersionPrinted: true,
|
|
66
|
+
tablet: 1199,
|
|
67
|
+
phone: 899,
|
|
68
|
+
prefix: 'v-',
|
|
69
|
+
easing: [0.25, 0.1, 0.25, 1],
|
|
70
|
+
resizeDebounce: 16,
|
|
71
|
+
hasWebpSupportCheck: true,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
enumerable: false,
|
|
75
|
+
configurable: true
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(Application.prototype, "prefix", {
|
|
78
|
+
/** Vevet prefix */
|
|
79
|
+
get: function () {
|
|
80
|
+
return this._props.prefix;
|
|
81
|
+
},
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(Application.prototype, "isPhone", {
|
|
86
|
+
/** Is phone device */
|
|
87
|
+
get: function () {
|
|
88
|
+
return this._isPhone;
|
|
89
|
+
},
|
|
90
|
+
enumerable: false,
|
|
91
|
+
configurable: true
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(Application.prototype, "isTablet", {
|
|
94
|
+
/** Is tablet device */
|
|
95
|
+
get: function () {
|
|
96
|
+
return this._isTablet;
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(Application.prototype, "isMobile", {
|
|
102
|
+
/** Is phone device */
|
|
103
|
+
get: function () {
|
|
104
|
+
return this._isMobile;
|
|
105
|
+
},
|
|
106
|
+
enumerable: false,
|
|
107
|
+
configurable: true
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(Application.prototype, "isDesktop", {
|
|
110
|
+
/** Is desktop device */
|
|
111
|
+
get: function () {
|
|
112
|
+
return this._isDesktop;
|
|
113
|
+
},
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(Application.prototype, "osName", {
|
|
118
|
+
/** Operating system name */
|
|
119
|
+
get: function () {
|
|
120
|
+
return this._osName;
|
|
121
|
+
},
|
|
122
|
+
enumerable: false,
|
|
123
|
+
configurable: true
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(Application.prototype, "browserName", {
|
|
126
|
+
/** Browser name */
|
|
127
|
+
get: function () {
|
|
128
|
+
return this._browserName;
|
|
129
|
+
},
|
|
130
|
+
enumerable: false,
|
|
131
|
+
configurable: true
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(Application.prototype, "isWebpSupported", {
|
|
134
|
+
/** WebP supported */
|
|
135
|
+
get: function () {
|
|
136
|
+
return this._isWebpSupported;
|
|
137
|
+
},
|
|
138
|
+
enumerable: false,
|
|
139
|
+
configurable: true
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(Application.prototype, "pageLoad", {
|
|
142
|
+
/** Page Load Callbacks */
|
|
143
|
+
get: function () {
|
|
144
|
+
return this._pageLoad;
|
|
145
|
+
},
|
|
146
|
+
enumerable: false,
|
|
147
|
+
configurable: true
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(Application.prototype, "viewport", {
|
|
150
|
+
/** Viewport Callbacks */
|
|
151
|
+
get: function () {
|
|
152
|
+
return this._viewport;
|
|
153
|
+
},
|
|
154
|
+
enumerable: false,
|
|
155
|
+
configurable: true
|
|
156
|
+
});
|
|
93
157
|
/** Get and set device info */
|
|
94
|
-
_setDeviceFeatures() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
158
|
+
Application.prototype._setDeviceFeatures = function () {
|
|
159
|
+
var _this = this;
|
|
160
|
+
var _a = this, prefix = _a.prefix, html = _a.html;
|
|
161
|
+
var _b = getDeviceInfo(), osName = _b.osName, browserName = _b.browserName, device = _b.device;
|
|
162
|
+
html.classList.add("".concat(prefix, "os-").concat(osName));
|
|
98
163
|
this._osName = osName;
|
|
99
|
-
html.classList.add(
|
|
164
|
+
html.classList.add("".concat(prefix, "browser-").concat(browserName));
|
|
100
165
|
this._browserName = browserName;
|
|
101
166
|
this._isPhone = device.phone;
|
|
102
|
-
html.classList.toggle(
|
|
167
|
+
html.classList.toggle("".concat(prefix, "phone"), this._isPhone);
|
|
103
168
|
this._isTablet = device.tablet;
|
|
104
|
-
html.classList.toggle(
|
|
169
|
+
html.classList.toggle("".concat(prefix, "tablet"), this._isTablet);
|
|
105
170
|
this._isMobile = device.phone || device.tablet;
|
|
106
|
-
html.classList.toggle(
|
|
171
|
+
html.classList.toggle("".concat(prefix, "mobile"), this._isMobile);
|
|
107
172
|
this._isDesktop = !this._isMobile;
|
|
108
|
-
html.classList.toggle(
|
|
173
|
+
html.classList.toggle("".concat(prefix, "desktop"), this._isDesktop);
|
|
109
174
|
// check webp support
|
|
110
175
|
if (this.props.hasWebpSupportCheck) {
|
|
111
176
|
fetchWebpSupport()
|
|
112
|
-
.then(()
|
|
113
|
-
|
|
177
|
+
.then(function () {
|
|
178
|
+
_this._isWebpSupported = true;
|
|
114
179
|
})
|
|
115
|
-
.catch(()
|
|
180
|
+
.catch(function () { });
|
|
116
181
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
182
|
+
};
|
|
183
|
+
Object.defineProperty(Application.prototype, "doc", {
|
|
184
|
+
/** Document element */
|
|
185
|
+
get: function () {
|
|
186
|
+
return document;
|
|
187
|
+
},
|
|
188
|
+
enumerable: false,
|
|
189
|
+
configurable: true
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(Application.prototype, "html", {
|
|
192
|
+
/** HTML element */
|
|
193
|
+
get: function () {
|
|
194
|
+
return document.documentElement;
|
|
195
|
+
},
|
|
196
|
+
enumerable: false,
|
|
197
|
+
configurable: true
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(Application.prototype, "body", {
|
|
200
|
+
/** Body element */
|
|
201
|
+
get: function () {
|
|
202
|
+
return document.body;
|
|
203
|
+
},
|
|
204
|
+
enumerable: false,
|
|
205
|
+
configurable: true
|
|
206
|
+
});
|
|
130
207
|
/** Action on page loaded */
|
|
131
|
-
onPageLoad() {
|
|
132
|
-
|
|
133
|
-
|
|
208
|
+
Application.prototype.onPageLoad = function () {
|
|
209
|
+
var _this = this;
|
|
210
|
+
return new PCancelable(function (resolve) {
|
|
211
|
+
return _this._pageLoad.onLoad(resolve);
|
|
212
|
+
});
|
|
213
|
+
};
|
|
134
214
|
/** Output current version */
|
|
135
|
-
_printVersion() {
|
|
215
|
+
Application.prototype._printVersion = function () {
|
|
136
216
|
if (!this.props.isVersionPrinted) {
|
|
137
217
|
return;
|
|
138
218
|
}
|
|
139
|
-
|
|
140
|
-
|
|
219
|
+
var msg = "Vevet ".concat(this.version);
|
|
220
|
+
var style = [
|
|
141
221
|
'padding: 1rem 1.5rem;',
|
|
142
222
|
'background: #5F2580;',
|
|
143
223
|
'font: 1rem/1 Arial;',
|
|
@@ -145,6 +225,8 @@ export class Application {
|
|
|
145
225
|
].join('');
|
|
146
226
|
// eslint-disable-next-line no-console
|
|
147
227
|
console.log('%c%s', style, msg);
|
|
148
|
-
}
|
|
149
|
-
|
|
228
|
+
};
|
|
229
|
+
return Application;
|
|
230
|
+
}());
|
|
231
|
+
export { Application };
|
|
150
232
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Application/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Application/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB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AAQ,CAAC;QAClB,CAAC;;;OAAA;IAGD,sBAAI,6BAAI;QADR,mBAAmB;aACnB;YACE,OAAO,QAAQ,CAAC,eAAe,CAAC;QAClC,CAAC;;;OAAA;IAGD,sBAAI,6BAAI;QADR,mBAAmB;aACnB;YACE,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;;;OAAA;IAED,4BAA4B;IACrB,gCAAU,GAAjB;QAAA,iBAIC;QAHC,OAAO,IAAI,WAAW,CAAC,UAAC,OAA8B;YACpD,OAAA,KAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;QAA9B,CAA8B,CAC/B,CAAC;IACJ,CAAC;IAED,6BAA6B;IACrB,mCAAa,GAArB;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAChC,OAAO;SACR;QAED,IAAM,GAAG,GAAG,gBAAS,IAAI,CAAC,OAAO,CAAE,CAAC;QAEpC,IAAM,KAAK,GAAG;YACZ,uBAAuB;YACvB,sBAAsB;YACtB,qBAAqB;YACrB,iBAAiB;SAClB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEX,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACH,kBAAC;AAAD,CAAC,AA5MD,IA4MC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import { uid, normalizedTimeoutCallback } from '../../utils/common';
|
|
2
13
|
/**
|
|
3
14
|
* A set of callbacks
|
|
4
15
|
*/
|
|
5
|
-
|
|
6
|
-
/** Vevet Application */
|
|
7
|
-
get app() {
|
|
8
|
-
return this._app;
|
|
9
|
-
}
|
|
10
|
-
/** List of callbacks */
|
|
11
|
-
get callbacks() {
|
|
12
|
-
return this._callbacks;
|
|
13
|
-
}
|
|
16
|
+
var Callbacks = /** @class */ (function () {
|
|
14
17
|
/**
|
|
15
18
|
* @param canInit - Defines if you need to call {@linkcode Callbacks._init} at the constructor's end.
|
|
16
19
|
* If no, you will have to call {@linkcode Callbacks._init} manually.
|
|
@@ -30,15 +33,32 @@ export class Callbacks {
|
|
|
30
33
|
* timeout: 50,
|
|
31
34
|
* });
|
|
32
35
|
*/
|
|
33
|
-
|
|
36
|
+
function Callbacks(canInit) {
|
|
37
|
+
if (canInit === void 0) { canInit = true; }
|
|
34
38
|
this._app = window.vevetApp;
|
|
35
39
|
this._callbacks = [];
|
|
36
40
|
if (canInit) {
|
|
37
41
|
this._init();
|
|
38
42
|
}
|
|
39
43
|
}
|
|
44
|
+
Object.defineProperty(Callbacks.prototype, "app", {
|
|
45
|
+
/** Vevet Application */
|
|
46
|
+
get: function () {
|
|
47
|
+
return this._app;
|
|
48
|
+
},
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(Callbacks.prototype, "callbacks", {
|
|
53
|
+
/** List of callbacks */
|
|
54
|
+
get: function () {
|
|
55
|
+
return this._callbacks;
|
|
56
|
+
},
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
40
60
|
/** Initialize the class */
|
|
41
|
-
_init() { }
|
|
61
|
+
Callbacks.prototype._init = function () { };
|
|
42
62
|
/**
|
|
43
63
|
* Adds a callback
|
|
44
64
|
*
|
|
@@ -46,96 +66,109 @@ export class Callbacks {
|
|
|
46
66
|
* @param action - Callback function
|
|
47
67
|
* @param settings - Callback settings
|
|
48
68
|
*/
|
|
49
|
-
add(target, action, settings
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
Callbacks.prototype.add = function (target, action, settings) {
|
|
70
|
+
var _this = this;
|
|
71
|
+
if (settings === void 0) { settings = {}; }
|
|
72
|
+
var id = uid('callback');
|
|
73
|
+
this._callbacks.push(__assign({ id: id, isEnabled: true, target: target, action: action }, settings));
|
|
52
74
|
this._onAdd(id);
|
|
53
75
|
return {
|
|
54
|
-
id,
|
|
55
|
-
remove: ()
|
|
76
|
+
id: id,
|
|
77
|
+
remove: function () { return _this.remove(id); },
|
|
56
78
|
};
|
|
57
|
-
}
|
|
79
|
+
};
|
|
58
80
|
/**
|
|
59
81
|
* Use it to implement some actions after adding a callback
|
|
60
82
|
*/
|
|
61
83
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
_onAdd(id) { }
|
|
84
|
+
Callbacks.prototype._onAdd = function (id) { };
|
|
63
85
|
/** Remove a callback */
|
|
64
|
-
remove(callbackId) {
|
|
86
|
+
Callbacks.prototype.remove = function (callbackId) {
|
|
65
87
|
return this._remove(callbackId);
|
|
66
|
-
}
|
|
88
|
+
};
|
|
67
89
|
/** Remove a callback */
|
|
68
|
-
_remove(callbackId, canRemoveProtected
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
Callbacks.prototype._remove = function (callbackId, canRemoveProtected) {
|
|
91
|
+
var _this = this;
|
|
92
|
+
if (canRemoveProtected === void 0) { canRemoveProtected = false; }
|
|
93
|
+
var isRemoved = false;
|
|
94
|
+
this._callbacks = this._callbacks.filter(function (_a) {
|
|
95
|
+
var id = _a.id, isProtected = _a.isProtected;
|
|
71
96
|
if (id !== callbackId) {
|
|
72
97
|
return true;
|
|
73
98
|
}
|
|
74
99
|
if (isProtected && !canRemoveProtected) {
|
|
75
100
|
return true;
|
|
76
101
|
}
|
|
77
|
-
|
|
102
|
+
_this._onRemove(id);
|
|
78
103
|
isRemoved = true;
|
|
79
104
|
return false;
|
|
80
105
|
});
|
|
81
106
|
return isRemoved;
|
|
82
|
-
}
|
|
107
|
+
};
|
|
83
108
|
/**
|
|
84
109
|
* Use it to implement some actions after removing a callback
|
|
85
110
|
*/
|
|
86
111
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
-
_onRemove(id) { }
|
|
112
|
+
Callbacks.prototype._onRemove = function (id) { };
|
|
88
113
|
/** Remove all callbacks */
|
|
89
|
-
_removeAll() {
|
|
114
|
+
Callbacks.prototype._removeAll = function () {
|
|
90
115
|
while (this._callbacks.length > 0) {
|
|
91
116
|
this._remove(this._callbacks[0].id, true);
|
|
92
117
|
}
|
|
93
|
-
}
|
|
118
|
+
};
|
|
94
119
|
/** Enable/disable a callback */
|
|
95
|
-
turn(id, isEnabled
|
|
96
|
-
|
|
120
|
+
Callbacks.prototype.turn = function (id, isEnabled) {
|
|
121
|
+
if (isEnabled === void 0) { isEnabled = true; }
|
|
122
|
+
var callback = this.get(id);
|
|
97
123
|
if (!callback) {
|
|
98
124
|
return;
|
|
99
125
|
}
|
|
100
126
|
callback.isEnabled = isEnabled;
|
|
101
127
|
this._onTurn(id);
|
|
102
|
-
}
|
|
128
|
+
};
|
|
103
129
|
/**
|
|
104
130
|
* Use it to implement some actions after enabling or disabling a callback.
|
|
105
131
|
*/
|
|
106
132
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
-
_onTurn(id) { }
|
|
133
|
+
Callbacks.prototype._onTurn = function (id) { };
|
|
108
134
|
/** Get a callback by id */
|
|
109
|
-
get(callbackId) {
|
|
110
|
-
|
|
135
|
+
Callbacks.prototype.get = function (callbackId) {
|
|
136
|
+
var callbacks = this._callbacks.filter(function (_a) {
|
|
137
|
+
var id = _a.id;
|
|
138
|
+
return id === callbackId;
|
|
139
|
+
});
|
|
111
140
|
return callbacks[0] || undefined;
|
|
112
|
-
}
|
|
141
|
+
};
|
|
113
142
|
/**
|
|
114
143
|
* Launch callback action. It will work only if the callback is enabled
|
|
115
144
|
*/
|
|
116
|
-
_callAction
|
|
145
|
+
Callbacks.prototype._callAction = function (_a, parameter) {
|
|
146
|
+
var id = _a.id, isEnabled = _a.isEnabled, timeout = _a.timeout, isOnce = _a.isOnce, action = _a.action;
|
|
117
147
|
if (!isEnabled) {
|
|
118
148
|
return;
|
|
119
149
|
}
|
|
120
|
-
normalizedTimeoutCallback(()
|
|
150
|
+
normalizedTimeoutCallback(function () { return action(parameter); }, timeout !== null && timeout !== void 0 ? timeout : 0);
|
|
121
151
|
if (isOnce) {
|
|
122
152
|
this._remove(id, true);
|
|
123
153
|
}
|
|
124
|
-
}
|
|
154
|
+
};
|
|
125
155
|
/**
|
|
126
156
|
* Trigger by target.
|
|
127
157
|
* Trigger all enabled callbacks under a certain target name.
|
|
128
158
|
*/
|
|
129
|
-
tbt(target, arg) {
|
|
130
|
-
|
|
159
|
+
Callbacks.prototype.tbt = function (target, arg) {
|
|
160
|
+
var _this = this;
|
|
161
|
+
this._callbacks.forEach(function (callback) {
|
|
131
162
|
if (callback.target === target) {
|
|
132
|
-
|
|
163
|
+
_this._callAction(callback, arg);
|
|
133
164
|
}
|
|
134
165
|
});
|
|
135
|
-
}
|
|
166
|
+
};
|
|
136
167
|
/** Destroy the callbacks */
|
|
137
|
-
destroy() {
|
|
168
|
+
Callbacks.prototype.destroy = function () {
|
|
138
169
|
this._removeAll();
|
|
139
|
-
}
|
|
140
|
-
|
|
170
|
+
};
|
|
171
|
+
return Callbacks;
|
|
172
|
+
}());
|
|
173
|
+
export { Callbacks };
|
|
141
174
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/base/Callbacks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAKhE;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/base/Callbacks/index.ts"],"names":[],"mappings":";;;;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.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
1
16
|
import { Module } from '../Module';
|
|
2
17
|
/**
|
|
3
18
|
* A class for Components.
|
|
4
19
|
*/
|
|
5
|
-
|
|
20
|
+
var Component = /** @class */ (function (_super) {
|
|
21
|
+
__extends(Component, _super);
|
|
22
|
+
function Component() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
6
25
|
/** Add a single plugin */
|
|
7
|
-
addPlugin(plugin) {
|
|
26
|
+
Component.prototype.addPlugin = function (plugin) {
|
|
8
27
|
if (typeof this._plugins === 'undefined') {
|
|
9
28
|
this._plugins = [];
|
|
10
29
|
}
|
|
@@ -12,16 +31,18 @@ export class Component extends Module {
|
|
|
12
31
|
// eslint-disable-next-line no-param-reassign
|
|
13
32
|
plugin.component = this;
|
|
14
33
|
plugin.init();
|
|
15
|
-
}
|
|
34
|
+
};
|
|
16
35
|
/** Destroy all plugins */
|
|
17
|
-
_destroyPlugins() {
|
|
36
|
+
Component.prototype._destroyPlugins = function () {
|
|
18
37
|
var _a;
|
|
19
|
-
(_a = this._plugins) === null || _a === void 0 ? void 0 : _a.forEach((plugin)
|
|
20
|
-
}
|
|
38
|
+
(_a = this._plugins) === null || _a === void 0 ? void 0 : _a.forEach(function (plugin) { return plugin.destroy(); });
|
|
39
|
+
};
|
|
21
40
|
/** Destroy the component */
|
|
22
|
-
_destroy() {
|
|
23
|
-
|
|
41
|
+
Component.prototype._destroy = function () {
|
|
42
|
+
_super.prototype._destroy.call(this);
|
|
24
43
|
this._destroyPlugins();
|
|
25
|
-
}
|
|
26
|
-
|
|
44
|
+
};
|
|
45
|
+
return Component;
|
|
46
|
+
}(Module));
|
|
47
|
+
export { Component };
|
|
27
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/base/Component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMnC;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/base/Component/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMnC;;GAEG;AACH;IAIU,6BAAoD;IAJ9D;;IAgCA,CAAC;IAxBC,0BAA0B;IACnB,6BAAS,GAAhB,UAAuD,MAAS;QAC9D,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,WAAW,EAAE;YACxC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;SACpB;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3B,6CAA6C;QAC7C,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,0BAA0B;IAClB,mCAAe,GAAvB;;QACE,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,OAAO,EAAE,EAAhB,CAAgB,CAAC,CAAC;IACvD,CAAC;IAED,4BAA4B;IAClB,4BAAQ,GAAlB;QACE,iBAAM,QAAQ,WAAE,CAAC;QAEjB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IACH,gBAAC;AAAD,CAAC,AAhCD,CAIU,MAAM,GA4Bf"}
|