ezal-theme-example 0.0.1 → 0.0.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.
|
@@ -152,12 +152,13 @@ export function initFootnote() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
function display(image: HTMLImageElement) {
|
|
155
|
-
const { top, left, width } = image.getBoundingClientRect();
|
|
156
|
-
const boxFrame = { background: '#0000' };
|
|
157
|
-
const frame = { top: `${top}px`, left: `${left}px`, width: `${width}px` };
|
|
158
|
-
const defaultDuration: number = 100;
|
|
155
|
+
const { top, left, width, height } = image.getBoundingClientRect();
|
|
159
156
|
const naturalWidth = image.naturalWidth;
|
|
160
157
|
const naturalHeight = image.naturalHeight;
|
|
158
|
+
const realWidth = (naturalWidth / naturalHeight) * height;
|
|
159
|
+
const realLeft = left + (width - realWidth) / 2;
|
|
160
|
+
const boxFrame = { background: '#0000' };
|
|
161
|
+
const defaultDuration: number = 100;
|
|
161
162
|
let currentWidth = 0;
|
|
162
163
|
let currentHeight = 0;
|
|
163
164
|
const box = $new('div');
|
|
@@ -184,7 +185,19 @@ function display(image: HTMLImageElement) {
|
|
|
184
185
|
hammer.get('pan').recognizeWith('pinch');
|
|
185
186
|
|
|
186
187
|
const hide = () => {
|
|
187
|
-
|
|
188
|
+
const { top, left, width, height } = image.getBoundingClientRect();
|
|
189
|
+
const realWidth = (naturalWidth / naturalHeight) * height;
|
|
190
|
+
const realLeft = left + (width - realWidth) / 2;
|
|
191
|
+
img.animate(
|
|
192
|
+
{
|
|
193
|
+
top: `${top}px`,
|
|
194
|
+
left: `${realLeft}px`,
|
|
195
|
+
width: `${realWidth}px`,
|
|
196
|
+
scale: 1,
|
|
197
|
+
translate: '0px 0px',
|
|
198
|
+
},
|
|
199
|
+
defaultDuration,
|
|
200
|
+
);
|
|
188
201
|
const animation = box.animate(boxFrame, defaultDuration);
|
|
189
202
|
animation.onfinish = () => {
|
|
190
203
|
box.remove();
|
|
@@ -231,7 +244,19 @@ function display(image: HTMLImageElement) {
|
|
|
231
244
|
resize();
|
|
232
245
|
doc.body.append(box);
|
|
233
246
|
box.animate([boxFrame, {}], defaultDuration).play();
|
|
234
|
-
img
|
|
247
|
+
img
|
|
248
|
+
.animate(
|
|
249
|
+
[
|
|
250
|
+
{
|
|
251
|
+
top: `${top}px`,
|
|
252
|
+
left: `${realLeft}px`,
|
|
253
|
+
width: `${realWidth}px`,
|
|
254
|
+
},
|
|
255
|
+
{},
|
|
256
|
+
],
|
|
257
|
+
{ duration: 300, easing: 'ease-in-out' },
|
|
258
|
+
)
|
|
259
|
+
.play();
|
|
235
260
|
image.style.opacity = '0';
|
|
236
261
|
|
|
237
262
|
let dragging = false;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ezal-theme-example",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"author": "jonnyjong",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"ezal": "^3.0.
|
|
9
|
+
"ezal": "^3.0.1"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=22"
|