mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 09:50:05 +08:00
first pass at removing setDefaultAttrs logic to speed up node instantation performance
This commit is contained in:
@@ -400,7 +400,7 @@ Test.Modules.PERFORMANCE = {
|
||||
anim.start();
|
||||
}, 4000);
|
||||
},
|
||||
'DRAWING - draw 10,000 small circles with tooltips': function(containerId) {
|
||||
'*DRAWING - draw 10,000 small circles with tooltips': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
@@ -408,7 +408,7 @@ Test.Modules.PERFORMANCE = {
|
||||
});
|
||||
|
||||
var circlesLayer = new Kinetic.Layer();
|
||||
var tooltipLayer = new Kinetic.Layer();
|
||||
|
||||
var colors = ["red", "orange", "yellow", "green", "blue", "cyan", "purple"];
|
||||
var colorIndex = 0;
|
||||
|
||||
@@ -425,47 +425,19 @@ Test.Modules.PERFORMANCE = {
|
||||
var randX = Math.random() * stage.getWidth();
|
||||
var randY = Math.random() * stage.getHeight();
|
||||
|
||||
var circle = new Kinetic.Ellipse({
|
||||
var circle = new Kinetic.Circle({
|
||||
x: randX,
|
||||
y: randY,
|
||||
radius: 2,
|
||||
fill: color
|
||||
});
|
||||
|
||||
circle.on("mousemove", function() {
|
||||
// update tooltip
|
||||
console.log('mouseover')
|
||||
var mousePos = stage.getMousePosition();
|
||||
tooltip.setPosition(mousePos.x + 5, mousePos.y + 5);
|
||||
tooltip.setText("node: " + i + ", color: " + color);
|
||||
tooltip.show();
|
||||
tooltipLayer.draw();
|
||||
});
|
||||
|
||||
circle.on("mouseout", function() {
|
||||
tooltip.hide();
|
||||
tooltipLayer.draw();
|
||||
});
|
||||
|
||||
circlesLayer.add(circle);
|
||||
}());
|
||||
}
|
||||
|
||||
var tooltip = new Kinetic.Text({
|
||||
text: "",
|
||||
fontFamily: "Calibri",
|
||||
fontSize: 12,
|
||||
padding: 5,
|
||||
visible: false,
|
||||
fill: "black",
|
||||
alpha: 0.75,
|
||||
textFill: "white"
|
||||
});
|
||||
|
||||
tooltipLayer.add(tooltip);
|
||||
|
||||
stage.add(circlesLayer);
|
||||
stage.add(tooltipLayer);
|
||||
|
||||
endTimer('drew 10,000 circles');
|
||||
|
||||
|
@@ -855,6 +855,8 @@ Test.Modules.CONTAINER = {
|
||||
stage.add(greenLayer);
|
||||
|
||||
blueLayer.setZIndex(1);
|
||||
|
||||
console.log(greenLayer.getZIndex());
|
||||
|
||||
test(greenLayer.getZIndex() === 0, 'green layer should have z index of 0');
|
||||
test(blueLayer.getZIndex() === 1, 'blue layer should have z index of 1');
|
||||
|
@@ -21,13 +21,13 @@ Test.Modules.DD = {
|
||||
layer.draw();
|
||||
|
||||
// test defaults
|
||||
test(circle.attrs.draggable === false, 'draggable should be false');
|
||||
test(circle.isDraggable() === false, 'draggable should be false');
|
||||
|
||||
//change properties
|
||||
circle.setDraggable(true);
|
||||
|
||||
// test new properties
|
||||
test(circle.attrs.draggable === true, 'draggable should be true');
|
||||
test(circle.getDraggable() === true, 'draggable should be true');
|
||||
},
|
||||
'DRAG AND DROP - multiple drag and drop sets with setDraggable()': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
|
@@ -852,7 +852,7 @@ Test.Modules.NODE = {
|
||||
|
||||
showHit(layer);
|
||||
},
|
||||
'hide group': function(containerId) {
|
||||
'hide group 2': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
@@ -2611,6 +2611,9 @@ Test.Modules.NODE = {
|
||||
|
||||
layer.hide();
|
||||
layer.draw();
|
||||
|
||||
console.log(layer.toDataURL());
|
||||
|
||||
test(layer.toDataURL() === dataUrls['cleared'], 'layer is still visible');
|
||||
},
|
||||
'hide group': function(containerId) {
|
||||
|
@@ -561,7 +561,7 @@ Test.Modules.SHAPE = {
|
||||
test(circle.getDashArrayEnabled() === true, 'dashArrayEnabled should be true');
|
||||
|
||||
circle.disableFill();
|
||||
|
||||
|
||||
test(circle.getFillEnabled() === false, 'fillEnabled should be false');
|
||||
test(circle.getStrokeEnabled() === true, 'strokeEnabled should be true');
|
||||
test(circle.getShadowEnabled() === true, 'shadowEnabled should be true');
|
||||
|
@@ -256,12 +256,16 @@ Test.Modules.Text = {
|
||||
|
||||
var width = text.getWidth();
|
||||
var height = text.getHeight();
|
||||
|
||||
|
||||
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
text.setFontSize(30);
|
||||
layer.draw();
|
||||
|
||||
//console.log(text.getHeight() + ',' + height);
|
||||
|
||||
test(text.getWidth() > width, 'text box width should have increased.');
|
||||
test(text.getHeight() > height, 'text box height should have increased.');
|
||||
|
@@ -67,37 +67,6 @@ Test.Modules.STAGE = {
|
||||
test(layer.getCanvas().element.width === 333, 'layer canvas element width should be 333');
|
||||
test(layer.getCanvas().element.height === 155, 'layer canvas element width should be 155');
|
||||
},
|
||||
'reset stage': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200,
|
||||
x: 100
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
var group = new Kinetic.Group();
|
||||
var circle = new Kinetic.Circle({
|
||||
x: stage.getWidth() / 2,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: 70,
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
name: 'myCircle',
|
||||
draggable: true
|
||||
});
|
||||
|
||||
stage.add(layer);
|
||||
layer.add(group);
|
||||
group.add(circle);
|
||||
layer.draw();
|
||||
|
||||
test(stage.getChildren().length === 1, 'stage should have one child');
|
||||
test(stage.getX() === 100, 'stage x should be 100');
|
||||
stage.reset();
|
||||
test(stage.getChildren().length === 0, 'stage should have no children');
|
||||
test(stage.getX() === 0, 'stage x should be 0');
|
||||
},
|
||||
'get stage DOM': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
|
Reference in New Issue
Block a user