@leafer-in/view 1.0.0-rc.19 → 1.0.0-rc.20
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 +2 -2
- package/dist/view.esm.min.js +1 -1
- package/dist/view.js +2 -2
- package/dist/view.min.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -2
package/dist/view.esm.js
CHANGED
|
@@ -59,7 +59,7 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed) {
|
|
|
59
59
|
}
|
|
60
60
|
if (changeScale) {
|
|
61
61
|
if (changeScale !== 1)
|
|
62
|
-
zoomLayer.scaleOfWorld(center, this.
|
|
62
|
+
zoomLayer.scaleOfWorld(center, this.getValidScale(changeScale));
|
|
63
63
|
}
|
|
64
64
|
else if (typeof zoomType === 'object') {
|
|
65
65
|
const isArray = zoomType instanceof Array;
|
|
@@ -78,7 +78,7 @@ Leafer.prototype.zoom = function (zoomType, padding, fixed) {
|
|
|
78
78
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
const fitScale = this.
|
|
81
|
+
const fitScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height));
|
|
82
82
|
moveX += (limitBounds.width - width * fitScale) / 2;
|
|
83
83
|
moveY += (limitBounds.height - height * fitScale) / 2;
|
|
84
84
|
zoomLayer.scaleOfWorld(bounds, fitScale);
|
package/dist/view.esm.min.js
CHANGED
|
@@ -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;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.
|
|
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.getValidScale(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.getValidScale(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
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
if (changeScale) {
|
|
62
62
|
if (changeScale !== 1)
|
|
63
|
-
zoomLayer.scaleOfWorld(center, this.
|
|
63
|
+
zoomLayer.scaleOfWorld(center, this.getValidScale(changeScale));
|
|
64
64
|
}
|
|
65
65
|
else if (typeof zoomType === 'object') {
|
|
66
66
|
const isArray = zoomType instanceof Array;
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
-
const fitScale = this.
|
|
82
|
+
const fitScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height));
|
|
83
83
|
moveX += (limitBounds.width - width * fitScale) / 2;
|
|
84
84
|
moveY += (limitBounds.height - height * fitScale) / 2;
|
|
85
85
|
zoomLayer.scaleOfWorld(bounds, fitScale);
|
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;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.
|
|
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.getValidScale(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.getValidScale(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.
|
|
3
|
+
"version": "1.0.0-rc.20",
|
|
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.
|
|
31
|
+
"@leafer-ui/draw": "1.0.0-rc.20"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
35
|
-
"@leafer-in/interface": "1.0.0-rc.
|
|
34
|
+
"@leafer-ui/interface": "1.0.0-rc.20",
|
|
35
|
+
"@leafer-in/interface": "1.0.0-rc.20"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,7 +42,7 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
|
|
|
42
42
|
|
|
43
43
|
if (changeScale) {
|
|
44
44
|
|
|
45
|
-
if (changeScale !== 1) zoomLayer.scaleOfWorld(center, this.
|
|
45
|
+
if (changeScale !== 1) zoomLayer.scaleOfWorld(center, this.getValidScale(changeScale))
|
|
46
46
|
|
|
47
47
|
} else if (typeof zoomType === 'object') {
|
|
48
48
|
|
|
@@ -66,7 +66,7 @@ Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fi
|
|
|
66
66
|
|
|
67
67
|
} else {
|
|
68
68
|
|
|
69
|
-
const fitScale = this.
|
|
69
|
+
const fitScale = this.getValidScale(Math.min(limitBounds.width / width, limitBounds.height / height))
|
|
70
70
|
moveX += (limitBounds.width - width * fitScale) / 2
|
|
71
71
|
moveY += (limitBounds.height - height * fitScale) / 2
|
|
72
72
|
|