-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(controls) textbox changeWidth control handler (#6219)
- Loading branch information
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(function(){ | ||
QUnit.module('fabric.controlHandlers', function(hooks) { | ||
var eventData, transform; | ||
var canvas = new fabric.Canvas(null); | ||
hooks.beforeEach(function() { | ||
var target = new fabric.Rect({ width: 100, height: 100 }); | ||
canvas.add(target); | ||
eventData = { | ||
}; | ||
transform = { | ||
originX: 'left', | ||
orginY: 'top', | ||
target: target, | ||
}; | ||
}); | ||
hooks.afterEach(function() { | ||
canvas.clear(); | ||
}); | ||
QUnit.test('changeWidth changes the width', function(assert) { | ||
assert.equal(transform.target.width, 100); | ||
fabric.controlHandlers.changeWidth(eventData, transform, 200, 300); | ||
assert.equal(transform.target.width, 199); | ||
}); | ||
QUnit.test('changeWidth changes the width with big strokeWidth', function(assert) { | ||
transform.target.strokeWidth = 15; | ||
fabric.controlHandlers.changeWidth(eventData, transform, 200, 300); | ||
assert.equal(transform.target.width, 185); | ||
}); | ||
QUnit.test('changeWidth changes the width with big strokeWidth and strokeUniform', function(assert) { | ||
transform.target.strokeWidth = 15; | ||
transform.target.strokeUniform = true; | ||
fabric.controlHandlers.changeWidth(eventData, transform, 200, 300); | ||
assert.equal(transform.target.width, 185); | ||
}); | ||
QUnit.test('changeWidth changes the width with big strokeWidth and strokeUniform + scaling', function(assert) { | ||
transform.target.strokeWidth = 15; | ||
transform.target.strokeUniform = true; | ||
transform.target.scaleX = 3; | ||
fabric.controlHandlers.changeWidth(eventData, transform, 200, 300); | ||
assert.equal(Math.floor(transform.target.width), 61); | ||
}); | ||
QUnit.test('changeWidth changes the width with big strokeWidth + scaling', function(assert) { | ||
transform.target.strokeWidth = 15; | ||
transform.target.scaleX = 3; | ||
fabric.controlHandlers.changeWidth(eventData, transform, 200, 300); | ||
assert.equal(Math.floor(transform.target.width), 51); | ||
}); | ||
}); | ||
})(); |