emacroh5lib 1.0.45 → 1.0.48
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/package.json
CHANGED
@@ -227,36 +227,56 @@
|
|
227
227
|
|
228
228
|
// Reset zoom action
|
229
229
|
resetZoom(adaptive = true) {
|
230
|
-
|
230
|
+
const image = this.image;
|
231
|
+
|
232
|
+
let { width, height } = image;
|
233
|
+
if (adaptive) {
|
234
|
+
let rate = 1
|
235
|
+
if (width > height) {
|
236
|
+
rate = width / document.body.clientWidth
|
237
|
+
} else {
|
238
|
+
rate = height / document.body.clientHeight
|
239
|
+
}
|
240
|
+
width = width / rate
|
241
|
+
height = height / rate
|
242
|
+
}
|
231
243
|
|
232
|
-
|
233
|
-
|
244
|
+
this.setStyleByName(image, "width", `${width}px`);
|
245
|
+
this.setStyleByName(image, "height", `${height}px`);
|
246
|
+
|
247
|
+
if (this.listDataCache[this.index] != null) {
|
248
|
+
this.listDataCache[this.index].width = `${width}px`;
|
249
|
+
this.listDataCache[this.index].height = `${height}px`;
|
250
|
+
}
|
234
251
|
|
235
|
-
const imageObject = new Image();
|
236
252
|
|
237
|
-
imageObject.src = this.list[this.index];
|
238
253
|
|
239
|
-
|
240
|
-
imageObject
|
254
|
+
// --------------------------------------------------------------------------------------------------
|
255
|
+
// const imageObject = new Image();
|
256
|
+
// imageObject.src = this.list[this.index];
|
257
|
+
// const $this = this
|
258
|
+
// imageObject.onload = () => {
|
241
259
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
260
|
+
// let { width, height } = imageObject;
|
261
|
+
// if (adaptive) {
|
262
|
+
// let rate = 1
|
263
|
+
// if (width > height) {
|
264
|
+
// rate = width / document.body.clientWidth
|
265
|
+
// } else {
|
266
|
+
// rate = height / document.body.clientHeight
|
267
|
+
// }
|
268
|
+
// width = width / rate
|
269
|
+
// height = height / rate
|
270
|
+
// }
|
271
|
+
|
272
|
+
// $this.setStyleByName(image, "width", `${width}px`);
|
273
|
+
// $this.setStyleByName(image, "height", `${height}px`);
|
274
|
+
|
275
|
+
// $this.listDataCache[this.index].width = `${width}px`;
|
276
|
+
// $this.listDataCache[this.index].height = `${height}px`;
|
277
|
+
// }
|
253
278
|
|
254
|
-
$this.setStyleByName(image, "width", `${width}px`);
|
255
|
-
$this.setStyleByName(image, "height", `${height}px`);
|
256
279
|
|
257
|
-
$this.listDataCache[this.index].width = `${width}px`;
|
258
|
-
$this.listDataCache[this.index].height = `${height}px`;
|
259
|
-
}
|
260
280
|
},
|
261
281
|
|
262
282
|
// Reset all action
|
@@ -298,8 +318,8 @@
|
|
298
318
|
|
299
319
|
// Get element current transform
|
300
320
|
getCurrentTransform(obj) {
|
301
|
-
let value
|
302
|
-
|
321
|
+
let value;
|
322
|
+
const transform = this.getStyleByName(obj, "transform");
|
303
323
|
|
304
324
|
if (transform === "none") return;
|
305
325
|
|
@@ -337,14 +357,12 @@
|
|
337
357
|
|
338
358
|
setTimeout(() => {
|
339
359
|
|
340
|
-
|
360
|
+
if (this.currentData) {
|
341
361
|
this.setStyleByName(this.image, "width", this.currentData.width);
|
342
362
|
this.setStyleByName(this.image, "height", this.currentData.height);
|
343
363
|
this.setStyleByName(this.image, "left", this.currentData.left);
|
344
364
|
this.setStyleByName(this.image, "top", this.currentData.top);
|
345
365
|
this.setTransform(this.image, this.currentData.transform);
|
346
|
-
} catch (error) {
|
347
|
-
console.log("switchAction", error, this.image, this.currentData);
|
348
366
|
}
|
349
367
|
|
350
368
|
this.resetZoom();
|