mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00
changed wrapping attribute to wrap
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
WORD = 'word',
|
WORD = 'word',
|
||||||
CHAR = 'char',
|
CHAR = 'char',
|
||||||
NONE = 'none',
|
NONE = 'none',
|
||||||
ATTR_CHANGE_LIST = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height', 'wrapping'],
|
ATTR_CHANGE_LIST = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height', 'wrap'],
|
||||||
|
|
||||||
// cached variables
|
// cached variables
|
||||||
attrChangeListLen = ATTR_CHANGE_LIST.length,
|
attrChangeListLen = ATTR_CHANGE_LIST.length,
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
* @param {Number} [config.width] default is auto
|
* @param {Number} [config.width] default is auto
|
||||||
* @param {Number} [config.height] default is auto
|
* @param {Number} [config.height] default is auto
|
||||||
* @param {Number} [config.lineHeight] default is 1
|
* @param {Number} [config.lineHeight] default is 1
|
||||||
* @param {String} [config.wrapping] can be word, char, or none. Default is word
|
* @param {String} [config.wrap] can be word, char, or none. Default is word
|
||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
@@ -229,9 +229,9 @@
|
|||||||
fixedHeight = height !== AUTO,
|
fixedHeight = height !== AUTO,
|
||||||
maxHeightPx = height - this.getPadding() * 2,
|
maxHeightPx = height - this.getPadding() * 2,
|
||||||
currentHeightPx = 0,
|
currentHeightPx = 0,
|
||||||
wrapping = this.getWrapping(),
|
wrap = this.getWrap(),
|
||||||
shouldWrap = wrapping !== NONE,
|
shouldWrap = wrap !== NONE,
|
||||||
wrapAtWord = wrapping !== CHAR && shouldWrap;
|
wrapAtWord = wrap !== CHAR && shouldWrap;
|
||||||
|
|
||||||
this.textArr = [];
|
this.textArr = [];
|
||||||
dummyContext.save();
|
dummyContext.save();
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
Kinetic.Node.addGetterSetter(Kinetic.Text, 'padding', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.Text, 'padding', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Text, 'align', LEFT);
|
Kinetic.Node.addGetterSetter(Kinetic.Text, 'align', LEFT);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Text, 'lineHeight', 1);
|
Kinetic.Node.addGetterSetter(Kinetic.Text, 'lineHeight', 1);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Text, 'wrapping', NONE);
|
Kinetic.Node.addGetterSetter(Kinetic.Text, 'wrap', NONE);
|
||||||
|
|
||||||
Kinetic.Node.addGetter(Kinetic.Text, TEXT, EMPTY_STRING);
|
Kinetic.Node.addGetter(Kinetic.Text, TEXT, EMPTY_STRING);
|
||||||
|
|
||||||
|
@@ -186,7 +186,7 @@ Test.Modules.Text = {
|
|||||||
padding: 0,
|
padding: 0,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
draggable: true,
|
draggable: true,
|
||||||
wrapping: 'WORD'
|
wrap: 'WORD'
|
||||||
});
|
});
|
||||||
|
|
||||||
// center text box
|
// center text box
|
||||||
@@ -395,7 +395,7 @@ Test.Modules.Text = {
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontFamily: 'Calibri',
|
fontFamily: 'Calibri',
|
||||||
fill: '#000',
|
fill: '#000',
|
||||||
wrapping: 'word'
|
wrap: 'word'
|
||||||
});
|
});
|
||||||
|
|
||||||
layer.add(text);
|
layer.add(text);
|
||||||
@@ -403,11 +403,11 @@ Test.Modules.Text = {
|
|||||||
|
|
||||||
warn(layer.toDataURL() === dataUrls['wrapped text']['wrapping to words'], 'text should be wrapped to words');
|
warn(layer.toDataURL() === dataUrls['wrapped text']['wrapping to words'], 'text should be wrapped to words');
|
||||||
|
|
||||||
text.setWrapping('none');
|
text.setWrap('none');
|
||||||
layer.draw();
|
layer.draw();
|
||||||
warn(layer.toDataURL() === dataUrls['wrapped text']['no wrapping'], 'text should not be wrapped');
|
warn(layer.toDataURL() === dataUrls['wrapped text']['no wrapping'], 'text should not be wrapped');
|
||||||
|
|
||||||
text.setWrapping('char');
|
text.setWrap('char');
|
||||||
layer.draw();
|
layer.draw();
|
||||||
warn(layer.toDataURL() === dataUrls['wrapped text']['wrapping to chars'], 'text should be wrapped to chars');
|
warn(layer.toDataURL() === dataUrls['wrapped text']['wrapping to chars'], 'text should be wrapped to chars');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user