@leafer-in/view 1.0.10 → 1.1.1

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.cjs CHANGED
@@ -31,7 +31,7 @@ function getFixBounds(bounds, scaleBounds) {
31
31
 
32
32
  draw.Leafer.prototype.zoom = function (zoomType, padding, fixed) {
33
33
  const { zoomLayer } = this;
34
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new draw.Bounds();
34
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new draw.Bounds();
35
35
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
36
36
  let changeScale;
37
37
  const { scaleX } = this.__;
package/dist/view.esm.js CHANGED
@@ -29,7 +29,7 @@ function getFixBounds(bounds, scaleBounds) {
29
29
 
30
30
  Leafer.prototype.zoom = function (zoomType, padding, fixed) {
31
31
  const { zoomLayer } = this;
32
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds();
32
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
33
33
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
34
34
  let changeScale;
35
35
  const { scaleX } = this.__;
@@ -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.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};
1
+ import{Leafer as t,Bounds as e,LeafBoundsHelper as i}from"@leafer-ui/draw";function o(t,e){let i=1;const o="out"===e,h=Math.abs(t);if(h>1){for(;o?i<h:i<=h;)i*=2;o&&(i/=2)}else{for(;o?i>=h:i>h;)i/=2;o||(i*=2)}return i/t}t.prototype.zoom=function(t,h,s){const{zoomLayer:n}=this,a=this.canvas.bounds.clone().shrink(void 0!==h?h: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=o(l,"in");break;case"out":d=o(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 o=e?t:[t];r.setListWithFn(o,i.worldBounds)}else{const e=function(t,e){let i,{x:o,y:h,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:o,y:h,width:s,height:n}:t}(t,a);r.set(n.getWorldBounds(e))}const{x:o,y:h,width:c,height:d}=r;let l=a.x-o,f=a.y-h;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
@@ -30,7 +30,7 @@
30
30
 
31
31
  draw.Leafer.prototype.zoom = function (zoomType, padding, fixed) {
32
32
  const { zoomLayer } = this;
33
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new draw.Bounds();
33
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new draw.Bounds();
34
34
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
35
35
  let changeScale;
36
36
  const { scaleX } = this.__;
package/dist/view.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw");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 d;const{scaleX:c}=this.__;if("string"==typeof i)switch(i){case"in":d=e(c,"in");break;case"out":d=e(c,"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&&(d=i/c);if(d)1!==d&&h.scaleOfWorld(r,this.getValidScale(d));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:d,height:c}=a;let l=n.x-s,u=n.y-r;if(o)l+=Math.max((n.width-d)/2,0),u+=Math.max((n.height-c)/2,0);else{const t=this.getValidScale(Math.min(n.width/d,n.height/c));l+=(n.width-d*t)/2,u+=(n.height-c*t)/2,h.scaleOfWorld(a,t),a.scaleOf(a,t)}return h.move(l,u),a.move(l,u)}return h.worldBoxBounds};
1
+ "use strict";var t=require("@leafer-ui/draw");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(void 0!==s?s:30),a=new t.Bounds,r={x:n.x+n.width/2,y:n.y+n.height/2};let d;const{scaleX:c}=this.__;if("string"==typeof i)switch(i){case"in":d=e(c,"in");break;case"out":d=e(c,"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&&(d=i/c);if(d)1!==d&&h.scaleOfWorld(r,this.getValidScale(d));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:d,height:c}=a;let l=n.x-s,u=n.y-r;if(o)l+=Math.max((n.width-d)/2,0),u+=Math.max((n.height-c)/2,0);else{const t=this.getValidScale(Math.min(n.width/d,n.height/c));l+=(n.width-d*t)/2,u+=(n.height-c*t)/2,h.scaleOfWorld(a,t),a.scaleOf(a,t)}return h.move(l,u),a.move(l,u)}return h.worldBoxBounds};
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.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);
1
+ !function(t){"use strict";function e(t,e){let i=1;const o="out"===e,s=Math.abs(t);if(s>1){for(;o?i<s:i<=s;)i*=2;o&&(i/=2)}else{for(;o?i>=s:i>s;)i/=2;o||(i*=2)}return i/t}t.Leafer.prototype.zoom=function(i,o,s){const{zoomLayer:h}=this,n=this.canvas.bounds.clone().shrink(void 0!==o?o:30),a=new t.Bounds,d={x:n.x+n.width/2,y:n.y+n.height/2};let r;const{scaleX:c}=this.__;if("string"==typeof i)switch(i){case"in":r=e(c,"in");break;case"out":r=e(c,"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&&(r=i/c);if(r)1!==r&&h.scaleOfWorld(d,this.getValidScale(r));else if("object"==typeof i){const e=i instanceof Array;if(e||i.tag){const o=e?i:[i];a.setListWithFn(o,t.LeafBoundsHelper.worldBounds)}else{const t=function(t,e){let i,{x:o,y:s,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:o,y:s,width:h,height:n}:t}(i,n);a.set(h.getWorldBounds(t))}const{x:o,y:d,width:r,height:c}=a;let f=n.x-o,l=n.y-d;if(s)f+=Math.max((n.width-r)/2,0),l+=Math.max((n.height-c)/2,0);else{const t=this.getValidScale(Math.min(n.width/r,n.height/c));f+=(n.width-r*t)/2,l+=(n.height-c*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.10",
3
+ "version": "1.1.1",
4
4
  "description": "@leafer-in/view",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@leafer-ui/draw": "^1.0.10",
38
- "@leafer-ui/interface": "^1.0.10",
39
- "@leafer-in/interface": "^1.0.10"
37
+ "@leafer-ui/draw": "^1.1.1",
38
+ "@leafer-ui/interface": "^1.1.1",
39
+ "@leafer-in/interface": "^1.1.1"
40
40
  }
41
41
  }
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@ import { getFixBounds, getZoomScale } from './helper'
7
7
  Leafer.prototype.zoom = function (zoomType: IZoomType, padding?: IFourNumber, fixed?: boolean): IBoundsData {
8
8
 
9
9
  const { zoomLayer } = this
10
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds()
10
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? 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
13
  let changeScale: number