@leafer-in/view 1.0.0-rc.18 → 1.0.0-rc.19

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/dist/view.esm.js CHANGED
@@ -31,15 +31,15 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed) {
31
31
  const { zoomLayer } = this;
32
32
  const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds();
33
33
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
34
- let scale;
34
+ let changeScale;
35
+ const { scaleX } = this.__;
35
36
  if (typeof zoomType === 'string') {
36
- const { scaleX } = this.__;
37
37
  switch (zoomType) {
38
38
  case 'in':
39
- scale = getZoomScale(scaleX, 'in');
39
+ changeScale = getZoomScale(scaleX, 'in');
40
40
  break;
41
41
  case 'out':
42
- scale = getZoomScale(scaleX, 'out');
42
+ changeScale = getZoomScale(scaleX, 'out');
43
43
  break;
44
44
  case 'fit':
45
45
  zoomType = this.boxBounds;
@@ -55,10 +55,11 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed) {
55
55
  }
56
56
  }
57
57
  else if (typeof zoomType === 'number') {
58
- scale = zoomType;
58
+ changeScale = zoomType / scaleX;
59
59
  }
60
- if (scale) {
61
- zoomLayer.scaleOfWorld(center, this.validScale(scale));
60
+ if (changeScale) {
61
+ if (changeScale !== 1)
62
+ zoomLayer.scaleOfWorld(center, this.validScale(changeScale));
62
63
  }
63
64
  else if (typeof zoomType === 'object') {
64
65
  const isArray = zoomType instanceof Array;
@@ -1 +1 @@
1
- import{Leafer as t,Bounds as e,LeafBoundsHelper as i}from"@leafer-ui/draw";function h(t,e){let i=1;const h="out"===e,o=Math.abs(t);if(o>1){for(;h?i<o:i<=o;)i*=2;h&&(i/=2)}else{for(;h?i>=o:i>o;)i/=2;h||(i*=2)}return i/t}t.prototype.zoom=function(t,o,s){const{zoomLayer:n}=this,a=this.canvas.bounds.clone().shrink(o||30),r=new e,c={x:a.x+a.width/2,y:a.y+a.height/2};let d;if("string"==typeof t){const{scaleX:i}=this.__;switch(t){case"in":d=h(i,"in");break;case"out":d=h(i,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new e(this.boxBounds)).height=0;break;case"fit-height":(t=new e(this.boxBounds)).width=0}}else"number"==typeof t&&(d=t);if(d)n.scaleOfWorld(c,this.validScale(d));else if("object"==typeof t){const e=t instanceof Array;if(e||t.tag){const h=e?t:[t];r.setListWithFn(h,i.worldBounds)}else{const e=function(t,e){let i,{x:h,y:o,width:s,height:n}=t;return n||(n=s*(e.height/e.width),i=!0),s||(s=n*(e.width/e.height),i=!0),i?{x:h,y:o,width:s,height:n}:t}(t,a);r.set(n.getWorldBounds(e))}const{x:h,y:o,width:c,height:d}=r;let l=a.x-h,f=a.y-o;if(s)l+=Math.max((a.width-c)/2,0),f+=Math.max((a.height-d)/2,0);else{const t=this.validScale(Math.min(a.width/c,a.height/d));l+=(a.width-c*t)/2,f+=(a.height-d*t)/2,n.scaleOfWorld(r,t),r.scaleOf(r,t)}return n.move(l,f),r.move(l,f)}return n.worldBoxBounds};
1
+ import{Leafer as t,Bounds as e,LeafBoundsHelper as i}from"@leafer-ui/draw";function h(t,e){let i=1;const h="out"===e,o=Math.abs(t);if(o>1){for(;h?i<o:i<=o;)i*=2;h&&(i/=2)}else{for(;h?i>=o:i>o;)i/=2;h||(i*=2)}return i/t}t.prototype.zoom=function(t,o,s){const{zoomLayer:n}=this,a=this.canvas.bounds.clone().shrink(o||30),r=new e,c={x:a.x+a.width/2,y:a.y+a.height/2};let d;const{scaleX:l}=this.__;if("string"==typeof t)switch(t){case"in":d=h(l,"in");break;case"out":d=h(l,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new e(this.boxBounds)).height=0;break;case"fit-height":(t=new e(this.boxBounds)).width=0}else"number"==typeof t&&(d=t/l);if(d)1!==d&&n.scaleOfWorld(c,this.validScale(d));else if("object"==typeof t){const e=t instanceof Array;if(e||t.tag){const h=e?t:[t];r.setListWithFn(h,i.worldBounds)}else{const e=function(t,e){let i,{x:h,y:o,width:s,height:n}=t;return n||(n=s*(e.height/e.width),i=!0),s||(s=n*(e.width/e.height),i=!0),i?{x:h,y:o,width:s,height:n}:t}(t,a);r.set(n.getWorldBounds(e))}const{x:h,y:o,width:c,height:d}=r;let l=a.x-h,f=a.y-o;if(s)l+=Math.max((a.width-c)/2,0),f+=Math.max((a.height-d)/2,0);else{const t=this.validScale(Math.min(a.width/c,a.height/d));l+=(a.width-c*t)/2,f+=(a.height-d*t)/2,n.scaleOfWorld(r,t),r.scaleOf(r,t)}return n.move(l,f),r.move(l,f)}return n.worldBoxBounds};
package/dist/view.js CHANGED
@@ -32,15 +32,15 @@
32
32
  const { zoomLayer } = this;
33
33
  const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new draw.Bounds();
34
34
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
35
- let scale;
35
+ let changeScale;
36
+ const { scaleX } = this.__;
36
37
  if (typeof zoomType === 'string') {
37
- const { scaleX } = this.__;
38
38
  switch (zoomType) {
39
39
  case 'in':
40
- scale = getZoomScale(scaleX, 'in');
40
+ changeScale = getZoomScale(scaleX, 'in');
41
41
  break;
42
42
  case 'out':
43
- scale = getZoomScale(scaleX, 'out');
43
+ changeScale = getZoomScale(scaleX, 'out');
44
44
  break;
45
45
  case 'fit':
46
46
  zoomType = this.boxBounds;
@@ -56,10 +56,11 @@
56
56
  }
57
57
  }
58
58
  else if (typeof zoomType === 'number') {
59
- scale = zoomType;
59
+ changeScale = zoomType / scaleX;
60
60
  }
61
- if (scale) {
62
- zoomLayer.scaleOfWorld(center, this.validScale(scale));
61
+ if (changeScale) {
62
+ if (changeScale !== 1)
63
+ zoomLayer.scaleOfWorld(center, this.validScale(changeScale));
63
64
  }
64
65
  else if (typeof zoomType === 'object') {
65
66
  const isArray = zoomType instanceof Array;
package/dist/view.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){"use strict";function e(t,e){let i=1;const s="out"===e,o=Math.abs(t);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/t}t.Leafer.prototype.zoom=function(i,s,o){const{zoomLayer:h}=this,n=this.canvas.bounds.clone().shrink(s||30),a=new t.Bounds,r={x:n.x+n.width/2,y:n.y+n.height/2};let c;if("string"==typeof i){const{scaleX:s}=this.__;switch(i){case"in":c=e(s,"in");break;case"out":c=e(s,"out");break;case"fit":i=this.boxBounds;break;case"fit-width":(i=new t.Bounds(this.boxBounds)).height=0;break;case"fit-height":(i=new t.Bounds(this.boxBounds)).width=0}}else"number"==typeof i&&(c=i);if(c)h.scaleOfWorld(r,this.validScale(c));else if("object"==typeof i){const e=i instanceof Array;if(e||i.tag){const s=e?i:[i];a.setListWithFn(s,t.LeafBoundsHelper.worldBounds)}else{const t=function(t,e){let i,{x:s,y:o,width:h,height:n}=t;return n||(n=h*(e.height/e.width),i=!0),h||(h=n*(e.width/e.height),i=!0),i?{x:s,y:o,width:h,height:n}:t}(i,n);a.set(h.getWorldBounds(t))}const{x:s,y:r,width:c,height:d}=a;let f=n.x-s,l=n.y-r;if(o)f+=Math.max((n.width-c)/2,0),l+=Math.max((n.height-d)/2,0);else{const t=this.validScale(Math.min(n.width/c,n.height/d));f+=(n.width-c*t)/2,l+=(n.height-d*t)/2,h.scaleOfWorld(a,t),a.scaleOf(a,t)}return h.move(f,l),a.move(f,l)}return h.worldBoxBounds}}(LeaferUI);
1
+ !function(t){"use strict";function e(t,e){let i=1;const s="out"===e,o=Math.abs(t);if(o>1){for(;s?i<o:i<=o;)i*=2;s&&(i/=2)}else{for(;s?i>=o:i>o;)i/=2;s||(i*=2)}return i/t}t.Leafer.prototype.zoom=function(i,s,o){const{zoomLayer:h}=this,n=this.canvas.bounds.clone().shrink(s||30),a=new t.Bounds,r={x:n.x+n.width/2,y:n.y+n.height/2};let c;const{scaleX:d}=this.__;if("string"==typeof i)switch(i){case"in":c=e(d,"in");break;case"out":c=e(d,"out");break;case"fit":i=this.boxBounds;break;case"fit-width":(i=new t.Bounds(this.boxBounds)).height=0;break;case"fit-height":(i=new t.Bounds(this.boxBounds)).width=0}else"number"==typeof i&&(c=i/d);if(c)1!==c&&h.scaleOfWorld(r,this.validScale(c));else if("object"==typeof i){const e=i instanceof Array;if(e||i.tag){const s=e?i:[i];a.setListWithFn(s,t.LeafBoundsHelper.worldBounds)}else{const t=function(t,e){let i,{x:s,y:o,width:h,height:n}=t;return n||(n=h*(e.height/e.width),i=!0),h||(h=n*(e.width/e.height),i=!0),i?{x:s,y:o,width:h,height:n}:t}(i,n);a.set(h.getWorldBounds(t))}const{x:s,y:r,width:c,height:d}=a;let f=n.x-s,l=n.y-r;if(o)f+=Math.max((n.width-c)/2,0),l+=Math.max((n.height-d)/2,0);else{const t=this.validScale(Math.min(n.width/c,n.height/d));f+=(n.width-c*t)/2,l+=(n.height-d*t)/2,h.scaleOfWorld(a,t),a.scaleOf(a,t)}return h.move(f,l),a.move(f,l)}return h.worldBoxBounds}}(LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/view",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.19",
4
4
  "description": "@leafer-in/view",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -28,10 +28,10 @@
28
28
  "leaferjs"
29
29
  ],
30
30
  "dependencies": {
31
- "@leafer-ui/draw": "1.0.0-rc.18"
31
+ "@leafer-ui/draw": "1.0.0-rc.19"
32
32
  },
33
33
  "devDependencies": {
34
- "@leafer-ui/interface": "1.0.0-rc.18",
35
- "@leafer-in/interface": "1.0.0-rc.18"
34
+ "@leafer-ui/interface": "1.0.0-rc.19",
35
+ "@leafer-in/interface": "1.0.0-rc.19"
36
36
  }
37
37
  }
package/src/index.ts CHANGED
@@ -10,18 +10,17 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
10
10
  const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds()
11
11
  const center: IPointData = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 }
12
12
 
13
- let scale: number
13
+ let changeScale: number
14
+ const { scaleX } = this.__
14
15
 
15
16
  if (typeof zoomType === 'string') {
16
17
 
17
- const { scaleX } = this.__
18
-
19
18
  switch (zoomType) {
20
19
  case 'in':
21
- scale = getZoomScale(scaleX, 'in')
20
+ changeScale = getZoomScale(scaleX, 'in')
22
21
  break
23
22
  case 'out':
24
- scale = getZoomScale(scaleX, 'out')
23
+ changeScale = getZoomScale(scaleX, 'out')
25
24
  break
26
25
  case 'fit':
27
26
  zoomType = this.boxBounds
@@ -37,13 +36,13 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
37
36
  }
38
37
 
39
38
  } else if (typeof zoomType === 'number') {
40
- scale = zoomType
39
+ changeScale = zoomType / scaleX
41
40
  }
42
41
 
43
42
 
44
- if (scale) {
43
+ if (changeScale) {
45
44
 
46
- zoomLayer.scaleOfWorld(center, this.validScale(scale))
45
+ if (changeScale !== 1) zoomLayer.scaleOfWorld(center, this.validScale(changeScale))
47
46
 
48
47
  } else if (typeof zoomType === 'object') {
49
48