emacroh5lib 1.0.52 → 1.0.55

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacroh5lib",
3
- "version": "1.0.52",
3
+ "version": "1.0.55",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -229,8 +229,35 @@
229
229
  resetZoom(adaptive = true) {
230
230
  const image = this.image;
231
231
 
232
- if (image != null && image.computed && image.width != null && image.height != null) {
233
- let { width, height } = image;
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
243
+ // }
244
+
245
+ // this.setStyleByName(image, "width", `${width}px`);
246
+ // this.setStyleByName(image, "height", `${height}px`);
247
+
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
+ // }
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;
234
261
  if (adaptive) {
235
262
  let rate = 1
236
263
  if (width > height) {
@@ -242,39 +269,11 @@
242
269
  height = height / rate
243
270
  }
244
271
 
245
- this.setStyleByName(image, "width", `${width}px`);
246
- this.setStyleByName(image, "height", `${height}px`);
247
-
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
- }
269
-
270
- $this.setStyleByName(image, "width", `${width}px`);
271
- $this.setStyleByName(image, "height", `${height}px`);
272
+ $this.setStyleByName(image, "width", `${width}px`);
273
+ $this.setStyleByName(image, "height", `${height}px`);
272
274
 
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
- }
275
+ this.listDataCache[this.index].width = `${width}px`;
276
+ this.listDataCache[this.index].height = `${height}px`;
278
277
  }
279
278
 
280
279
  },
@@ -357,29 +356,17 @@
357
356
 
358
357
  setTimeout(() => {
359
358
 
360
- let data = {
361
- transform: {
362
- scaleX: "1",
363
- skewY: "0",
364
- translateX: "-50%",
365
- translateY: "-50%",
366
- rotate: "0deg",
367
- },
368
- left: "50%",
369
- top: "50%",
370
- width: `${imageObject.width}px`,
371
- height: `${imageObject.height}px`,
372
- };
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
- data = this.currentData
376
- }
359
+ try {
360
+ const data = this.currentData
377
361
 
378
- this.setStyleByName(this.image, "width", data.width);
379
- this.setStyleByName(this.image, "height", data.height);
380
- this.setStyleByName(this.image, "left", data.left);
381
- this.setStyleByName(this.image, "top", data.top);
382
- this.setTransform(this.image, data.transform);
362
+ this.setStyleByName(this.image, "width", data.width);
363
+ this.setStyleByName(this.image, "height", data.height);
364
+ this.setStyleByName(this.image, "left", data.left);
365
+ this.setStyleByName(this.image, "top", data.top);
366
+ this.setTransform(this.image, data.transform);
367
+ } catch (error) {
368
+ console.log("switchAction", error, this.currentData);
369
+ }
383
370
 
384
371
  this.resetZoom();
385
372
  this.resetPosition();
@@ -427,19 +414,29 @@
427
414
  // Zoom action
428
415
  zoom(type) {
429
416
  let image = this.image;
417
+
418
+ console.log("报错1", image);
430
419
  let w = +this.getStyleByName(image, "width").split("px")[0];
431
420
  let h = +this.getStyleByName(image, "height").split("px")[0];
432
421
 
433
422
  if (h <= 20 && type === "out") return;
434
423
 
435
424
  if (type === "out") {
425
+ console.log("报错2", `${w * (1 - this.shrink)}px`);
436
426
  this.setStyleByName(image, "width", `${w * (1 - this.shrink)}px`);
437
427
  this.setStyleByName(image, "height", `${h * (1 - this.shrink)}px`);
428
+ console.log("报错3");
438
429
  } else {
430
+ console.log("报错4", `${w * (1 + this.enlarge)}px`);
439
431
  this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
440
432
  this.setStyleByName(image, "height", `${h * (1 + this.enlarge)}px`);
433
+ console.log("报错5");
441
434
  }
442
435
 
436
+ console.log("报错6", this.currentData);
437
+ console.log("报错7", image);
438
+ console.log("报错8", this.image);
439
+
443
440
  this.currentData.width = this.getStyleByName(this.image, "width");
444
441
  this.currentData.height = this.getStyleByName(this.image, "height");
445
442
  },