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,29 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.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
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
1
27
|
import { Component as ComponentClass } from '../../base/Component';
|
|
2
28
|
import { onResize } from '../../utils/internal/onResize';
|
|
3
29
|
/**
|
|
@@ -5,104 +31,144 @@ import { onResize } from '../../utils/internal/onResize';
|
|
|
5
31
|
* It creates an HTML5 Canvas element and its 2d context and can
|
|
6
32
|
* implement automatic resize.
|
|
7
33
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return this.props.container;
|
|
15
|
-
}
|
|
16
|
-
/** The Canvas element itself */
|
|
17
|
-
get canvas() {
|
|
18
|
-
return this._canvas;
|
|
19
|
-
}
|
|
20
|
-
/** 2D Context */
|
|
21
|
-
get ctx() {
|
|
22
|
-
return this._ctx;
|
|
23
|
-
}
|
|
24
|
-
/* Canvas width (with DPR) */
|
|
25
|
-
get width() {
|
|
26
|
-
return this._width;
|
|
27
|
-
}
|
|
28
|
-
/* Canvas width (without DPR) */
|
|
29
|
-
get clientWidth() {
|
|
30
|
-
return this.width / this.dpr;
|
|
31
|
-
}
|
|
32
|
-
/* Canvas height (with DPR) */
|
|
33
|
-
get height() {
|
|
34
|
-
return this._height;
|
|
35
|
-
}
|
|
36
|
-
/* Canvas height (without DPR) */
|
|
37
|
-
get clientHeight() {
|
|
38
|
-
return this.height / this.dpr;
|
|
39
|
-
}
|
|
40
|
-
/** Device pixel ratio */
|
|
41
|
-
get dpr() {
|
|
42
|
-
return this._dpr;
|
|
43
|
-
}
|
|
44
|
-
/** If content may be successfully rendered */
|
|
45
|
-
get canRender() {
|
|
46
|
-
return this.width > 0 && this.height > 0;
|
|
47
|
-
}
|
|
48
|
-
constructor(initialProps, canInit = true) {
|
|
49
|
-
super(initialProps, false);
|
|
50
|
-
const { isAppend, container } = this.props;
|
|
34
|
+
var Ctx2D = /** @class */ (function (_super) {
|
|
35
|
+
__extends(Ctx2D, _super);
|
|
36
|
+
function Ctx2D(initialProps, canInit) {
|
|
37
|
+
if (canInit === void 0) { canInit = true; }
|
|
38
|
+
var _this = _super.call(this, initialProps, false) || this;
|
|
39
|
+
var _a = _this.props, isAppend = _a.isAppend, container = _a.container;
|
|
51
40
|
// set default values
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
_this._width = 0;
|
|
42
|
+
_this._height = 0;
|
|
43
|
+
_this._dpr = 1;
|
|
55
44
|
// create canvas
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
_this._canvas = document.createElement('canvas');
|
|
46
|
+
_this._canvas.style.position = 'absolute';
|
|
47
|
+
_this._canvas.style.top = '0';
|
|
48
|
+
_this._canvas.style.left = '0';
|
|
49
|
+
_this._canvas.style.width = '100%';
|
|
50
|
+
_this._canvas.style.height = '100%';
|
|
62
51
|
// append canvas
|
|
63
52
|
if (isAppend && container instanceof Element) {
|
|
64
|
-
container.append(
|
|
65
|
-
|
|
53
|
+
container.append(_this._canvas);
|
|
54
|
+
_this.addDestroyableAction(function () { return _this.canvas.remove(); });
|
|
66
55
|
}
|
|
67
56
|
// create context
|
|
68
|
-
|
|
57
|
+
_this._ctx = _this._canvas.getContext('2d');
|
|
69
58
|
if (canInit) {
|
|
70
|
-
|
|
59
|
+
_this.init();
|
|
71
60
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
Ctx2D.prototype._getDefaultProps = function () {
|
|
64
|
+
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { container: false, isAppend: true, hasInitialResize: true, hasResize: false, viewportTarget: 'any', resizeDebounce: 0, width: 'auto', height: 'auto', dpr: 'auto' });
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(Ctx2D.prototype, "container", {
|
|
67
|
+
/** The parent element of the canvas */
|
|
68
|
+
get: function () {
|
|
69
|
+
return this.props.container;
|
|
70
|
+
},
|
|
71
|
+
enumerable: false,
|
|
72
|
+
configurable: true
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(Ctx2D.prototype, "canvas", {
|
|
75
|
+
/** The Canvas element itself */
|
|
76
|
+
get: function () {
|
|
77
|
+
return this._canvas;
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(Ctx2D.prototype, "ctx", {
|
|
83
|
+
/** 2D Context */
|
|
84
|
+
get: function () {
|
|
85
|
+
return this._ctx;
|
|
86
|
+
},
|
|
87
|
+
enumerable: false,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(Ctx2D.prototype, "width", {
|
|
91
|
+
/* Canvas width (with DPR) */
|
|
92
|
+
get: function () {
|
|
93
|
+
return this._width;
|
|
94
|
+
},
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(Ctx2D.prototype, "clientWidth", {
|
|
99
|
+
/* Canvas width (without DPR) */
|
|
100
|
+
get: function () {
|
|
101
|
+
return this.width / this.dpr;
|
|
102
|
+
},
|
|
103
|
+
enumerable: false,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(Ctx2D.prototype, "height", {
|
|
107
|
+
/* Canvas height (with DPR) */
|
|
108
|
+
get: function () {
|
|
109
|
+
return this._height;
|
|
110
|
+
},
|
|
111
|
+
enumerable: false,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(Ctx2D.prototype, "clientHeight", {
|
|
115
|
+
/* Canvas height (without DPR) */
|
|
116
|
+
get: function () {
|
|
117
|
+
return this.height / this.dpr;
|
|
118
|
+
},
|
|
119
|
+
enumerable: false,
|
|
120
|
+
configurable: true
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(Ctx2D.prototype, "dpr", {
|
|
123
|
+
/** Device pixel ratio */
|
|
124
|
+
get: function () {
|
|
125
|
+
return this._dpr;
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(Ctx2D.prototype, "canRender", {
|
|
131
|
+
/** If content may be successfully rendered */
|
|
132
|
+
get: function () {
|
|
133
|
+
return this.width > 0 && this.height > 0;
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
Ctx2D.prototype._onPropsMutate = function () {
|
|
139
|
+
_super.prototype._onPropsMutate.call(this);
|
|
75
140
|
this.resize();
|
|
76
|
-
}
|
|
77
|
-
_init() {
|
|
78
|
-
|
|
141
|
+
};
|
|
142
|
+
Ctx2D.prototype._init = function () {
|
|
143
|
+
_super.prototype._init.call(this);
|
|
79
144
|
this._setResize();
|
|
80
|
-
}
|
|
145
|
+
};
|
|
81
146
|
/** Set resize events */
|
|
82
|
-
_setResize() {
|
|
83
|
-
|
|
147
|
+
Ctx2D.prototype._setResize = function () {
|
|
148
|
+
var _this = this;
|
|
149
|
+
var _a = this.props, hasInitialResize = _a.hasInitialResize, hasResize = _a.hasResize, viewportTarget = _a.viewportTarget, resizeDebounce = _a.resizeDebounce;
|
|
84
150
|
if (!hasResize) {
|
|
85
151
|
return;
|
|
86
152
|
}
|
|
87
|
-
|
|
88
|
-
onResize: ()
|
|
153
|
+
var resizeHandler = onResize({
|
|
154
|
+
onResize: function () { return _this.resize(); },
|
|
89
155
|
element: this.container,
|
|
90
|
-
viewportTarget,
|
|
91
|
-
resizeDebounce,
|
|
156
|
+
viewportTarget: viewportTarget,
|
|
157
|
+
resizeDebounce: resizeDebounce,
|
|
92
158
|
});
|
|
93
|
-
this.addDestroyableAction(()
|
|
159
|
+
this.addDestroyableAction(function () { return resizeHandler.remove(); });
|
|
94
160
|
if (hasInitialResize) {
|
|
95
161
|
resizeHandler.resize();
|
|
96
162
|
}
|
|
97
|
-
}
|
|
163
|
+
};
|
|
98
164
|
/** Resize the canvas */
|
|
99
|
-
resize() {
|
|
100
|
-
|
|
165
|
+
Ctx2D.prototype.resize = function () {
|
|
166
|
+
var _a = this, props = _a.props, canvas = _a.canvas;
|
|
101
167
|
if (!canvas) {
|
|
102
168
|
return;
|
|
103
169
|
}
|
|
104
|
-
|
|
105
|
-
|
|
170
|
+
var app = this.app;
|
|
171
|
+
var viewport = app.viewport;
|
|
106
172
|
// calculate dpr
|
|
107
173
|
if (typeof props.dpr === 'number') {
|
|
108
174
|
this._dpr = props.dpr;
|
|
@@ -111,8 +177,8 @@ export class Ctx2D extends ComponentClass {
|
|
|
111
177
|
this._dpr = viewport.dpr;
|
|
112
178
|
}
|
|
113
179
|
// calculate new width & height
|
|
114
|
-
|
|
115
|
-
|
|
180
|
+
var newWidth = 0;
|
|
181
|
+
var newHeight = 0;
|
|
116
182
|
if (typeof props.width === 'number' && typeof props.height === 'number') {
|
|
117
183
|
newWidth = props.width;
|
|
118
184
|
newHeight = props.height;
|
|
@@ -137,11 +203,11 @@ export class Ctx2D extends ComponentClass {
|
|
|
137
203
|
// launch callbacks
|
|
138
204
|
this._handleResize();
|
|
139
205
|
this.callbacks.tbt('resize', undefined);
|
|
140
|
-
}
|
|
206
|
+
};
|
|
141
207
|
/** Method called on resize */
|
|
142
|
-
_handleResize() { }
|
|
208
|
+
Ctx2D.prototype._handleResize = function () { };
|
|
143
209
|
/** Render the scene if possible */
|
|
144
|
-
render(renderProp) {
|
|
210
|
+
Ctx2D.prototype.render = function (renderProp) {
|
|
145
211
|
if (!this.canRender) {
|
|
146
212
|
return;
|
|
147
213
|
}
|
|
@@ -154,6 +220,8 @@ export class Ctx2D extends ComponentClass {
|
|
|
154
220
|
clientHeight: this.clientHeight,
|
|
155
221
|
canvas: this.canvas,
|
|
156
222
|
});
|
|
157
|
-
}
|
|
158
|
-
|
|
223
|
+
};
|
|
224
|
+
return Ctx2D;
|
|
225
|
+
}(ComponentClass));
|
|
226
|
+
export { Ctx2D };
|
|
159
227
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Ctx2D/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIrD;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Ctx2D/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIrD;;;;GAIG;AACH;IAIU,yBAA4D;IA4EpE,eAAY,YAA4C,EAAE,OAAc;QAAd,wBAAA,EAAA,cAAc;QAAxE,YACE,kBAAM,YAAY,EAAE,KAAK,CAAC,SA8B3B;QA5BO,IAAA,KAA0B,KAAI,CAAC,KAAK,EAAlC,QAAQ,cAAA,EAAE,SAAS,eAAe,CAAC;QAE3C,qBAAqB;QACrB,KAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,KAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,KAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAEd,gBAAgB;Q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C,SAAS,CAAC,YAAY,CAAC;SACzC;aAAM;YACL,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;YAC1B,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;SAC7B;QAED,YAAY;QACZ,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC;QACtB,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC;QAEvB,eAAe;QACf,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAEzB,cAAc;QACd,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC;QACxB,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAE1B,mBAAmB;QACnB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,8BAA8B;IACpB,6BAAa,GAAvB,cAA2B,CAAC;IAE5B,mCAAmC;IAC5B,sBAAM,GAAb,UAAc,UAA0B;QACtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,OAAO;SACR;QAED,UAAU,CAAC;YACT,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IACH,YAAC;AAAD,CAAC,AAxND,CAIU,cAAc,GAoNvB"}
|
|
@@ -1,24 +1,56 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.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
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
1
27
|
import { getPos } from 'get-image-pos';
|
|
2
28
|
import { Ctx2D } from '../Ctx2D';
|
|
3
29
|
/**
|
|
4
30
|
* The class allows you to prerender media for further use with reduced payloads.
|
|
5
31
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
32
|
+
var Ctx2DPrerender = /** @class */ (function (_super) {
|
|
33
|
+
__extends(Ctx2DPrerender, _super);
|
|
34
|
+
function Ctx2DPrerender() {
|
|
35
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9
36
|
}
|
|
37
|
+
Ctx2DPrerender.prototype._getDefaultProps = function () {
|
|
38
|
+
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { media: false, posRule: 'cover' });
|
|
39
|
+
};
|
|
10
40
|
/** Method called on resize */
|
|
11
|
-
_handleResize() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
41
|
+
Ctx2DPrerender.prototype._handleResize = function () {
|
|
42
|
+
var _this = this;
|
|
43
|
+
_super.prototype._handleResize.call(this);
|
|
44
|
+
this.render(function (props) { return _this._prerender(props); });
|
|
45
|
+
};
|
|
15
46
|
/** Prerender the scene */
|
|
16
|
-
_prerender
|
|
17
|
-
|
|
47
|
+
Ctx2DPrerender.prototype._prerender = function (_a) {
|
|
48
|
+
var width = _a.width, height = _a.height, ctx = _a.ctx;
|
|
49
|
+
var _b = this.props, media = _b.media, posRule = _b.posRule;
|
|
18
50
|
// get source info
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
51
|
+
var source;
|
|
52
|
+
var sourceWidth;
|
|
53
|
+
var sourceHeight;
|
|
22
54
|
if (media instanceof Ctx2D) {
|
|
23
55
|
source = media.canvas;
|
|
24
56
|
sourceWidth = media.width;
|
|
@@ -28,20 +60,22 @@ export class Ctx2DPrerender extends Ctx2D {
|
|
|
28
60
|
source = media;
|
|
29
61
|
}
|
|
30
62
|
// get media sizes
|
|
31
|
-
|
|
32
|
-
source,
|
|
33
|
-
sourceWidth,
|
|
34
|
-
sourceHeight,
|
|
63
|
+
var size = getPos({
|
|
64
|
+
source: source,
|
|
65
|
+
sourceWidth: sourceWidth,
|
|
66
|
+
sourceHeight: sourceHeight,
|
|
35
67
|
rule: posRule,
|
|
36
68
|
scale: 1,
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
69
|
+
width: width,
|
|
70
|
+
height: height,
|
|
39
71
|
});
|
|
40
72
|
// render media
|
|
41
73
|
ctx.clearRect(0, 0, width, height);
|
|
42
74
|
ctx.drawImage(source, size.x, size.y, size.width, size.height);
|
|
43
75
|
// launch callbacks on prerender
|
|
44
76
|
this.callbacks.tbt('prerender', undefined);
|
|
45
|
-
}
|
|
46
|
-
|
|
77
|
+
};
|
|
78
|
+
return Ctx2DPrerender;
|
|
79
|
+
}(Ctx2D));
|
|
80
|
+
export { Ctx2DPrerender };
|
|
47
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Ctx2DPrerender/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;AAKzC;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Ctx2DPrerender/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;AAKzC;;GAEG;AACH;IAIU,kCAAmD;IAJ7D;;IAsDA,CAAC;IAjDW,yCAAgB,GAA1B;QACE,6BACK,iBAAM,gBAAgB,WAAE,KAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,IAChB;IACJ,CAAC;IAED,8BAA8B;IACpB,sCAAa,GAAvB;QAAA,iBAIC;QAHC,iBAAM,aAAa,WAAE,CAAC;QAEtB,IAAI,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAtB,CAAsB,CAAC,CAAC;IACjD,CAAC;IAED,0BAA0B;IAChB,mCAAU,GAApB,UAAqB,EAA2C;YAAzC,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,GAAG,SAAA;QACjC,IAAA,KAAqB,IAAI,CAAC,KAAK,EAA7B,KAAK,WAAA,EAAE,OAAO,aAAe,CAAC;QAEtC,kBAAkB;QAClB,IAAI,MAA0B,CAAC;QAC/B,IAAI,WAA+B,CAAC;QACpC,IAAI,YAAgC,CAAC;QACrC,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACtB,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC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