-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for IE11 IndexSizeError for negative source crops #5428
Conversation
@CaptEmulation eventually also the source width/height must be at max the naturalWidth/naturalHeight ( width/height ) of the element we are about to draw. Can you fix that too? |
Taking a looksee |
Add the additional boundary check and added a test. Could not follow test style because I could not run anything in image test suite (timeout). IDE also picked up on some reformatting. |
dist/fabric.js
Outdated
x, y, w, h); | ||
var elementToDraw = this._element, | ||
w = this.width, h = this.height, | ||
sW = Math.min(elementToDraw.naturalWidth || elementToDraw.width, w * this._filterScalingX), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sW = Math.min(elementToDraw.naturalWidth || elementToDraw.width, w * this._filterScalingX), | |
sW = Math.min(elementToDraw.naturalWidth || elementToDraw.width, w) * this._filterScalingX, |
we want to limit the source area, this._filterScaling apply anyway
dist/fabric.js
Outdated
var elementToDraw = this._element, | ||
w = this.width, h = this.height, | ||
sW = Math.min(elementToDraw.naturalWidth || elementToDraw.width, w * this._filterScalingX), | ||
sH = Math.min(elementToDraw.naturalHeight || elementToDraw.height, h * this._filterScalingY), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sH = Math.min(elementToDraw.naturalHeight || elementToDraw.height, h * this._filterScalingY), | |
sH = Math.min(elementToDraw.naturalHeight || elementToDraw.height, h) * this._filterScalingY, |
Thanks for the test too. i usually do |
Understood. Thanks and will do! |
oh well if there is a filter scaling, the elementToDraw is already resized to the right dimension of width * filterScalingX. So as you did in the first version, the code was right, with filterScaling inside the parenthesis. |
* Fix for IE11 IndexSizeError for negative source crops
This codepen will not render on IE11 https://codepen.io/captemulation/pen/PXPORb (copy to your own codepen and replace
pen
withdebug
to view on IE11)In IE11, if a negative number is passed in for sx or sy when using the 9 argument version of
drawImage
anIndexSizeError
exception will be thrown. This can occur with rounding errors making a number just past 0, e.g. -2.4e-12.Negative numbers do not really make sense here.