mirror of
https://github.com/konvajs/konva.git
synced 2026-01-22 03:11:53 +08:00
some bugs fixes
This commit is contained in:
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
* Fixed `Konva.Text` justify drawing for a text with decoration
|
* Fixed `Konva.Text` justify drawing for a text with decoration
|
||||||
|
* Added methods `data()`,`setData()` and `getData()` methods to `Konva.TextPath`
|
||||||
|
|
||||||
|
|
||||||
## [2.1.3][2018-05-17]
|
## [2.1.3][2018-05-17]
|
||||||
|
|||||||
28
konva.min.js
vendored
28
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -521,6 +521,26 @@
|
|||||||
Konva.Util.extend(Konva.TextPath, Konva.Shape);
|
Konva.Util.extend(Konva.TextPath, Konva.Shape);
|
||||||
|
|
||||||
// add setters and getters
|
// add setters and getters
|
||||||
|
Konva.Factory.addGetterSetter(Konva.TextPath, 'data');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set SVG path data string. This method
|
||||||
|
* also automatically parses the data string
|
||||||
|
* into a data array. Currently supported SVG data:
|
||||||
|
* M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z
|
||||||
|
* @name setData
|
||||||
|
* @method
|
||||||
|
* @memberof Konva.TextPath.prototype
|
||||||
|
* @param {String} SVG path command string
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get SVG path data string
|
||||||
|
* @name getData
|
||||||
|
* @method
|
||||||
|
* @memberof Konva.TextPath.prototype
|
||||||
|
*/
|
||||||
|
|
||||||
Konva.Factory.addGetterSetter(Konva.TextPath, 'fontFamily', 'Arial');
|
Konva.Factory.addGetterSetter(Konva.TextPath, 'fontFamily', 'Arial');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ suite('Caching', function() {
|
|||||||
cloneAndCompareLayer(layer, 150);
|
cloneAndCompareLayer(layer, 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.only('test group with circle + buffer canvas usage', function() {
|
test('test group with circle + buffer canvas usage', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
var layer = new Konva.Layer();
|
var layer = new Konva.Layer();
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
|||||||
@@ -1060,6 +1060,38 @@ suite('Stage', function() {
|
|||||||
assert.equal(stage.toDataURL(), layer.toDataURL());
|
assert.equal(stage.toDataURL(), layer.toDataURL());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('toCanvas with large size', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
|
var radius = stage.height() / 2 + 10;
|
||||||
|
var circle = new Konva.Circle({
|
||||||
|
x: stage.height() / 2,
|
||||||
|
y: stage.height() / 2,
|
||||||
|
fill: 'black',
|
||||||
|
radius: radius
|
||||||
|
});
|
||||||
|
layer.add(circle);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
var stageCanvas = stage.toCanvas({
|
||||||
|
x: -10,
|
||||||
|
y: -10,
|
||||||
|
width: stage.height() + 20,
|
||||||
|
height: stage.height() + 20
|
||||||
|
});
|
||||||
|
|
||||||
|
var canvas = createCanvas();
|
||||||
|
canvas.width = radius * 2;
|
||||||
|
canvas.height = radius * 2;
|
||||||
|
var context = canvas.getContext('2d');
|
||||||
|
context.beginPath();
|
||||||
|
context.arc(radius, radius, radius, 0, 2 * Math.PI);
|
||||||
|
context.fillStyle = 'black';
|
||||||
|
context.fill();
|
||||||
|
compareCanvases(stageCanvas, canvas, 100);
|
||||||
|
});
|
||||||
|
|
||||||
test('check hit graph with stage listening property', function() {
|
test('check hit graph with stage listening property', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
var layer = new Konva.Layer();
|
var layer = new Konva.Layer();
|
||||||
|
|||||||
@@ -286,6 +286,29 @@ suite('Line', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: FIX IT!!!
|
||||||
|
test.skip('getClientRect rotated', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
|
var line = new Konva.Line({
|
||||||
|
x: 20,
|
||||||
|
y: 20,
|
||||||
|
rotation: 45,
|
||||||
|
points: [0, 0, 50, 50],
|
||||||
|
closed: true,
|
||||||
|
stroke: '#0f0'
|
||||||
|
});
|
||||||
|
layer.add(line);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
var rect = line.getClientRect();
|
||||||
|
assert.equal(rect.x, 19, 'check x');
|
||||||
|
assert.equal(rect.y, 19, 'check y');
|
||||||
|
// assert.equal(rect.width, 2, 'check width');
|
||||||
|
assert.equal(rect.height, 52, 'check height');
|
||||||
|
});
|
||||||
|
|
||||||
test('line caching', function() {
|
test('line caching', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
var layer = new Konva.Layer();
|
var layer = new Konva.Layer();
|
||||||
|
|||||||
@@ -74,6 +74,28 @@ suite('TextPath', function() {
|
|||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('Check getter and setter', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
|
var c = 'M 50 50 l 250 0';
|
||||||
|
var path = new Konva.TextPath({
|
||||||
|
text: 'some text',
|
||||||
|
stroke: 'red',
|
||||||
|
strokeWidth: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(path);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
assert.equal(path.getData(), undefined);
|
||||||
|
path.data(c);
|
||||||
|
assert.equal(path.getData(), c);
|
||||||
|
|
||||||
|
layer.draw();
|
||||||
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('Render Text Along Vertical Line', function() {
|
test('Render Text Along Vertical Line', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|||||||
Reference in New Issue
Block a user