Skip to content

Commit

Permalink
fix(): add minScale property
Browse files Browse the repository at this point in the history
  • Loading branch information
alyleui committed Oct 25, 2018
1 parent 4d5c851 commit c94a7db
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/resizing-cropping-images/resizing-cropping-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export class LyResizingCroppingImages implements AfterContentInit {
private _img: HTMLImageElement;
private offset: {x: number, y: number, left: number, top: number};
private _scale: number;
private _config: ImgCropperConfig;
private _minScale: number;
private _config: ImgCropperConfig;

@ViewChild('_imgContainer') imgContainer: ElementRef;
@ViewChild('_croppingContainer') croppingContainer: ElementRef;
Expand All @@ -157,6 +157,10 @@ export class LyResizingCroppingImages implements AfterContentInit {
get scale() {
return this._scale;
}
/** get min scale */
get minScale() {
return this._minScale;
}
isLoaded: boolean;
isCropped: boolean;

Expand Down Expand Up @@ -229,7 +233,7 @@ export class LyResizingCroppingImages implements AfterContentInit {
/** Set the size of the image, the values can be 0 between 1, where 1 is the original size */
setScale(size: number) {
// fix min scale
size = size > this._minScale && size <= 1 ? size : this._minScale;
size = size > this.minScale && size <= 1 ? size : this.minScale;
this._scale = size;
size = size * 100;
const initialImg = this._img;
Expand Down Expand Up @@ -366,7 +370,7 @@ export class LyResizingCroppingImages implements AfterContentInit {
/**- */
zoomOut() {
const scale = this.roundNumber(this._scale - .05);
if (scale > this._minScale && scale <= 1) {
if (scale > this.minScale && scale <= 1) {
this.setScale(scale);
} else {
this.fit();
Expand Down

0 comments on commit c94a7db

Please sign in to comment.