emacroh5lib 1.0.44 → 1.0.47
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
@@ -54,7 +54,7 @@
|
|
54
54
|
viewerSrc: "",
|
55
55
|
image: null,
|
56
56
|
listDataCache: [],
|
57
|
-
index: 0
|
57
|
+
index: 0
|
58
58
|
};
|
59
59
|
},
|
60
60
|
props: {
|
@@ -123,6 +123,8 @@
|
|
123
123
|
}
|
124
124
|
},
|
125
125
|
},
|
126
|
+
mounted() {
|
127
|
+
},
|
126
128
|
methods: {
|
127
129
|
// Global init
|
128
130
|
init() {
|
@@ -133,7 +135,8 @@
|
|
133
135
|
// Init listDataCache
|
134
136
|
initListDataCache(index = 0) {
|
135
137
|
const promises = [];
|
136
|
-
|
138
|
+
|
139
|
+
const $this = null
|
137
140
|
|
138
141
|
this.list.forEach((item, i) => {
|
139
142
|
const imageObject = new Image();
|
@@ -176,24 +179,24 @@
|
|
176
179
|
// $this.setStyleByName($this.image, "width", width);
|
177
180
|
// $this.setStyleByName($this.image, "height", height);
|
178
181
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
const { width, height } =
|
183
|
-
|
184
|
-
|
182
|
+
this.image = this.$refs["duoViewerImage"];
|
183
|
+
this.initDrag();
|
184
|
+
this.$emit("loadComplete");
|
185
|
+
const { width, height } = this.listDataCache[index];
|
186
|
+
this.setStyleByName(this.image, "width", width);
|
187
|
+
this.setStyleByName(this.image, "height", height);
|
185
188
|
})
|
186
189
|
|
187
190
|
Promise.race(promises).then((data) => {
|
188
|
-
|
189
|
-
|
191
|
+
this.image = this.$refs["duoViewerImage"];
|
192
|
+
this.initDrag();
|
190
193
|
this.$emit("loadComplete");
|
191
|
-
const { width, height } =
|
192
|
-
|
193
|
-
|
194
|
+
const { width, height } = this.listDataCache[index];
|
195
|
+
this.setStyleByName(this.image, "width", width);
|
196
|
+
this.setStyleByName(this.image, "height", height);
|
194
197
|
|
195
198
|
setTimeout(() => {
|
196
|
-
|
199
|
+
this.resetZoom();
|
197
200
|
}, 100);
|
198
201
|
})
|
199
202
|
|
@@ -224,22 +227,16 @@
|
|
224
227
|
|
225
228
|
// Reset zoom action
|
226
229
|
resetZoom(adaptive = true) {
|
227
|
-
|
228
|
-
const imageObject = new Image();
|
229
|
-
|
230
|
-
imageObject.src = this.list[this.index];
|
231
|
-
|
232
|
-
let { width, height } = imageObject;
|
230
|
+
const image = this.image;
|
233
231
|
|
232
|
+
let { width, height } = image;
|
234
233
|
if (adaptive) {
|
235
234
|
let rate = 1
|
236
235
|
if (width > height) {
|
237
236
|
rate = width / document.body.clientWidth
|
238
|
-
}
|
239
|
-
else {
|
237
|
+
} else {
|
240
238
|
rate = height / document.body.clientHeight
|
241
239
|
}
|
242
|
-
|
243
240
|
width = width / rate
|
244
241
|
height = height / rate
|
245
242
|
}
|
@@ -249,6 +246,36 @@
|
|
249
246
|
|
250
247
|
this.listDataCache[this.index].width = `${width}px`;
|
251
248
|
this.listDataCache[this.index].height = `${height}px`;
|
249
|
+
|
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
|
+
|
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
|
+
// }
|
278
|
+
|
252
279
|
},
|
253
280
|
|
254
281
|
// Reset all action
|
@@ -286,7 +313,6 @@
|
|
286
313
|
// Set style by name
|
287
314
|
setStyleByName(obj, key, value) {
|
288
315
|
obj && (obj.style[key] = value);
|
289
|
-
|
290
316
|
},
|
291
317
|
|
292
318
|
// Get element current transform
|
@@ -330,14 +356,12 @@
|
|
330
356
|
|
331
357
|
setTimeout(() => {
|
332
358
|
|
333
|
-
|
359
|
+
if (this.currentData) {
|
334
360
|
this.setStyleByName(this.image, "width", this.currentData.width);
|
335
361
|
this.setStyleByName(this.image, "height", this.currentData.height);
|
336
362
|
this.setStyleByName(this.image, "left", this.currentData.left);
|
337
363
|
this.setStyleByName(this.image, "top", this.currentData.top);
|
338
364
|
this.setTransform(this.image, this.currentData.transform);
|
339
|
-
} catch (error) {
|
340
|
-
console.log("switchAction", error, this.image, this.currentData);
|
341
365
|
}
|
342
366
|
|
343
367
|
this.resetZoom();
|