mirror of
https://github.com/konvajs/konva.git
synced 2026-01-18 19:51:21 +08:00
changed draggable() to setDraggable(). added getDraggable(). added more unit tests and functional tests
This commit is contained in:
@@ -18,7 +18,7 @@ Test.prototype.tests = {
|
||||
stroke: 'black'
|
||||
});
|
||||
|
||||
circle.draggable(true);
|
||||
circle.setDraggable(true);
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
@@ -31,10 +31,6 @@ Test.prototype.tests = {
|
||||
dragStart = true;
|
||||
});
|
||||
|
||||
circle.on('dragstart', function() {
|
||||
dragStart = true;
|
||||
});
|
||||
|
||||
circle.on('dragmove', function() {
|
||||
dragMove = true;
|
||||
});
|
||||
@@ -80,6 +76,73 @@ Test.prototype.tests = {
|
||||
});
|
||||
});
|
||||
},
|
||||
'DRAG AND DROP - drag and drop layer': function(containerId) {
|
||||
var urls = dataUrls['DRAG AND DROP - drag and drop layer'];
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200,
|
||||
throttle: 999
|
||||
});
|
||||
var layer = new Kinetic.Layer({
|
||||
drawFunc: function() {
|
||||
var context = this.getContext();
|
||||
context.beginPath();
|
||||
context.moveTo(200, 50);
|
||||
context.lineTo(420, 80);
|
||||
context.quadraticCurveTo(300, 100, 260, 170);
|
||||
context.closePath();
|
||||
context.fillStyle = 'blue';
|
||||
context.fill();
|
||||
},
|
||||
draggable: true
|
||||
});
|
||||
|
||||
var circle1 = new Kinetic.Ellipse({
|
||||
x: stage.getWidth() / 2,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: 70,
|
||||
fill: 'red'
|
||||
});
|
||||
|
||||
var circle2 = new Kinetic.Ellipse({
|
||||
x: 400,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: 70,
|
||||
fill: 'green'
|
||||
});
|
||||
|
||||
layer.add(circle1);
|
||||
layer.add(circle2);
|
||||
|
||||
stage.add(layer);
|
||||
|
||||
stage.toDataURL(function(startDataUrl) {
|
||||
test(urls[0] === startDataUrl, 'start data url is incorrect');
|
||||
|
||||
/*
|
||||
* simulate drag and drop
|
||||
*/
|
||||
stage._mousedown({
|
||||
clientX: 399,
|
||||
clientY: 96
|
||||
});
|
||||
|
||||
stage._mousemove({
|
||||
clientX: 210,
|
||||
clientY: 109
|
||||
});
|
||||
|
||||
stage._mouseup({
|
||||
clientX: 210,
|
||||
clientY: 109
|
||||
});
|
||||
|
||||
stage.toDataURL(function(endDataUrl) {
|
||||
test(urls[1] === endDataUrl, 'end data url is incorrect');
|
||||
});
|
||||
});
|
||||
},
|
||||
'EVENTS - modify fill stroke and stroke width on hover with circle': function(containerId) {
|
||||
var urls = dataUrls['EVENTS - modify fill stroke and stroke width on hover with circle'];
|
||||
var stage = new Kinetic.Stage({
|
||||
|
||||
Reference in New Issue
Block a user