emacroh5lib 1.0.49 → 1.0.52
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
@@ -136,7 +136,7 @@
|
|
136
136
|
initListDataCache(index = 0) {
|
137
137
|
const promises = [];
|
138
138
|
|
139
|
-
const $this =
|
139
|
+
const $this = this
|
140
140
|
|
141
141
|
this.list.forEach((item, i) => {
|
142
142
|
const imageObject = new Image();
|
@@ -229,53 +229,53 @@
|
|
229
229
|
resetZoom(adaptive = true) {
|
230
230
|
const image = this.image;
|
231
231
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
232
|
+
if (image != null && image.computed && image.width != null && image.height != null) {
|
233
|
+
let { width, height } = image;
|
234
|
+
if (adaptive) {
|
235
|
+
let rate = 1
|
236
|
+
if (width > height) {
|
237
|
+
rate = width / document.body.clientWidth
|
238
|
+
} else {
|
239
|
+
rate = height / document.body.clientHeight
|
240
|
+
}
|
241
|
+
width = width / rate
|
242
|
+
height = height / rate
|
239
243
|
}
|
240
|
-
width = width / rate
|
241
|
-
height = height / rate
|
242
|
-
}
|
243
|
-
|
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
|
-
}
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
// --------------------------------------------------------------------------------------------------
|
255
|
-
// const imageObject = new Image();
|
256
|
-
// imageObject.src = this.list[this.index];
|
257
|
-
// const $this = this
|
258
|
-
// imageObject.onload = () => {
|
259
244
|
|
260
|
-
|
261
|
-
|
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
|
-
// }
|
245
|
+
this.setStyleByName(image, "width", `${width}px`);
|
246
|
+
this.setStyleByName(image, "height", `${height}px`);
|
271
247
|
|
272
|
-
|
273
|
-
|
248
|
+
if (this.listDataCache[this.index] != null) {
|
249
|
+
this.listDataCache[this.index].width = `${width}px`;
|
250
|
+
this.listDataCache[this.index].height = `${height}px`;
|
251
|
+
}
|
252
|
+
} else {
|
253
|
+
const imageObject = new Image();
|
254
|
+
imageObject.src = this.list[this.index];
|
255
|
+
const $this = this
|
256
|
+
imageObject.onload = () => {
|
257
|
+
|
258
|
+
let { width, height } = imageObject;
|
259
|
+
if (adaptive) {
|
260
|
+
let rate = 1
|
261
|
+
if (width > height) {
|
262
|
+
rate = width / document.body.clientWidth
|
263
|
+
} else {
|
264
|
+
rate = height / document.body.clientHeight
|
265
|
+
}
|
266
|
+
width = width / rate
|
267
|
+
height = height / rate
|
268
|
+
}
|
274
269
|
|
275
|
-
|
276
|
-
|
277
|
-
// }
|
270
|
+
$this.setStyleByName(image, "width", `${width}px`);
|
271
|
+
$this.setStyleByName(image, "height", `${height}px`);
|
278
272
|
|
273
|
+
if (this.listDataCache[this.index] != null) {
|
274
|
+
this.listDataCache[this.index].width = `${width}px`;
|
275
|
+
this.listDataCache[this.index].height = `${height}px`;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
279
|
|
280
280
|
},
|
281
281
|
|
@@ -370,8 +370,8 @@
|
|
370
370
|
width: `${imageObject.width}px`,
|
371
371
|
height: `${imageObject.height}px`,
|
372
372
|
};
|
373
|
-
if (this.currentData != null && this.currentData.width != null && this.currentData.height != null &&
|
374
|
-
|
373
|
+
if (this.currentData != null && this.currentData.width != null && this.currentData.height != null &&
|
374
|
+
this.currentData.left != null && this.currentData.top != null && this.currentData.transform != null) {
|
375
375
|
data = this.currentData
|
376
376
|
}
|
377
377
|
|