@behance/helicropter
Advanced tools
Comparing version 16.0.2 to 16.0.3
{ | ||
"name": "@behance/helicropter", | ||
"version": "16.0.2", | ||
"version": "16.0.3", | ||
"description": "My helicropter goes \"whosh whosh whosh\"", | ||
@@ -5,0 +5,0 @@ "main": "src/js/index.js", |
@@ -168,6 +168,8 @@ import View from '@behance/beff/View'; | ||
return Object.assign({}, retVal, { | ||
x: this._model.allowLetterboxing ? retVal.x : Math.max(0, retVal.x), | ||
y: this._model.allowLetterboxing ? retVal.y : Math.max(0, retVal.y), | ||
}); | ||
if (this._shouldClampBounds()) { | ||
retVal.x = Math.max(0, retVal.x); | ||
retVal.y = Math.max(0, retVal.y); | ||
} | ||
return retVal; | ||
}, | ||
@@ -197,6 +199,10 @@ | ||
_shouldClampBounds() { | ||
return !this._model.allowLetterboxing && !this._model.allowTransparency; | ||
}, | ||
_getReductionRatio(scaledValues) { | ||
let reductionRatio = 1; | ||
if (this._model.allowLetterboxing) { | ||
if (!this._shouldClampBounds()) { | ||
return reductionRatio; | ||
@@ -203,0 +209,0 @@ } |
@@ -308,2 +308,42 @@ import CroppingArea from 'CroppingArea'; | ||
it('allows x/y coordinates less than 0 when letterboxing', function() { | ||
this.croppingArea._model.allowLetterboxing = true; | ||
spyOn(this.croppingArea, '_getImageProp').and.returnValue(20); | ||
spyOn(this.croppingArea, '_getCropAreaProp').and.returnValue(0); | ||
this.croppingArea._cropArea.width = 100; | ||
this.croppingArea._cropArea.height = 50; | ||
this.croppingArea._image = { getScaleX: () => 1.0 }; | ||
expect(this.croppingArea.getCropData()).toEqual({ | ||
x: -20, | ||
y: -20, | ||
width: this.croppingArea._cropArea.width, | ||
height: this.croppingArea._cropArea.height, | ||
scale: 1.0, | ||
}); | ||
}); | ||
it('allows x/y coordinates less than 0 when transparency is allowed', function() { | ||
this.croppingArea._model.allowTransparency = true; | ||
spyOn(this.croppingArea, '_getImageProp').and.returnValue(10); | ||
spyOn(this.croppingArea, '_getCropAreaProp').and.returnValue(0); | ||
this.croppingArea._cropArea.width = 100; | ||
this.croppingArea._cropArea.height = 50; | ||
this.croppingArea._image = { getScaleX: () => 1.0 }; | ||
expect(this.croppingArea.getCropData()).toEqual({ | ||
x: -10, | ||
y: -10, | ||
width: this.croppingArea._cropArea.width, | ||
height: this.croppingArea._cropArea.height, | ||
scale: 1.0, | ||
}); | ||
}); | ||
it('does not allow height/width less than 1', function() { | ||
@@ -441,3 +481,16 @@ spyOn(this.croppingArea, '_getImageProp').and.returnValue(1); | ||
}); | ||
it('does not clamp coordinates to native width/height if scaled width/height is greater than native width/height and transparency is allowed', function() { | ||
this.croppingArea._model.allowTransparency = true; | ||
this.croppingArea._cropArea.width = 300; | ||
this.croppingArea._cropArea.height = 300; | ||
expect(this.croppingArea.getDimensions()).toEqual({ | ||
x: 10, | ||
y: 20, | ||
width: 600, | ||
height: 600, | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8705392
46
5067