fixed issue with stage panning. stage node type needs to be declared before calling super constructor

This commit is contained in:
Eric Rowell 2013-09-28 21:55:57 -07:00
parent a8cbc2321d
commit e13a0b5fd8
3 changed files with 14 additions and 6 deletions

View File

@ -215,7 +215,7 @@
context = canvas.getContext(), context = canvas.getContext(),
drawFunc = this.getDrawFunc(), drawFunc = this.getDrawFunc(),
applyShadow = this.hasShadow() && this.getShadowEnabled(), applyShadow = this.hasShadow() && this.getShadowEnabled(),
applyOpacity = this.getOpacity() !== 1, applyOpacity = this.getAbsoluteOpacity() !== 1,
stage, bufferCanvas, bufferContext; stage, bufferCanvas, bufferContext;
if(drawFunc && this.isVisible()) { if(drawFunc && this.isVisible()) {

View File

@ -55,9 +55,9 @@
Kinetic.Util.addMethods(Kinetic.Stage, { Kinetic.Util.addMethods(Kinetic.Stage, {
___init: function(config) { ___init: function(config) {
this.nodeType = STAGE;
// call super constructor // call super constructor
Kinetic.Container.call(this, config); Kinetic.Container.call(this, config);
this.nodeType = STAGE;
this._id = Kinetic.idCounter++; this._id = Kinetic.idCounter++;
this._buildDOM(); this._buildDOM();
this._bindContentEvents(); this._bindContentEvents();

View File

@ -399,9 +399,17 @@ suite('DragAndDropEvents', function() {
// ====================================================== // ======================================================
test('drag and drop stage', function() { test('drag and drop stage', function() {
var stage = addStage(); var container = document.createElement('div'),
stage = new Kinetic.Stage({
container: container,
width: 578,
height: 200,
draggable: true
});
stage.setDraggable(true); kineticContainer.appendChild(container);
//stage.setDraggable(true);
var layer = new Kinetic.Layer(); var layer = new Kinetic.Layer();
@ -424,7 +432,7 @@ suite('DragAndDropEvents', function() {
* simulate drag and drop * simulate drag and drop
*/ */
stage._mousedown({ stage._mousedown({
clientX: 100, clientX: 0,
clientY: 100 + top clientY: 100 + top
}); });
@ -440,7 +448,7 @@ suite('DragAndDropEvents', function() {
}); });
Kinetic.DD._endDragAfter(); Kinetic.DD._endDragAfter();
assert.equal(stage.getX(), 200); assert.equal(stage.getX(), 300);
assert.equal(stage.getY(), 10); assert.equal(stage.getY(), 10);