mirror of
https://github.com/konvajs/konva.git
synced 2025-04-30 09:34:20 +08:00
removed .onContent() and replaced with .getDOM()
This commit is contained in:
parent
9fef9e54d9
commit
222aea4e2e
41
dist/kinetic-core.js
vendored
41
dist/kinetic-core.js
vendored
@ -3,7 +3,7 @@
|
||||
* http://www.kineticjs.com/
|
||||
* Copyright 2012, Eric Rowell
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Apr 27 2012
|
||||
* Date: Apr 28 2012
|
||||
*
|
||||
* Copyright (C) 2011 - 2012 by Eric Rowell
|
||||
*
|
||||
@ -1200,7 +1200,7 @@ Kinetic.Container.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
;///////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Stage
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
@ -1476,18 +1476,6 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
this._remove(layer);
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* add layer to stage
|
||||
* @param {Layer} layer
|
||||
@ -1557,7 +1545,7 @@ Kinetic.Stage.prototype = {
|
||||
* @param {Object} point
|
||||
*/
|
||||
getIntersections: function() {
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var arr = [];
|
||||
var shapes = this.get('Shape');
|
||||
|
||||
@ -1570,6 +1558,13 @@ Kinetic.Stage.prototype = {
|
||||
|
||||
return arr;
|
||||
},
|
||||
/**
|
||||
* get stage DOM node, which is a div element
|
||||
* with the class name "kineticjs-content"
|
||||
*/
|
||||
getDOM: function() {
|
||||
return this.content;
|
||||
},
|
||||
/**
|
||||
* detect event
|
||||
* @param {Shape} shape
|
||||
@ -1924,7 +1919,7 @@ Kinetic.Stage.prototype = {
|
||||
_prepareDrag: function() {
|
||||
var that = this;
|
||||
|
||||
this.onContent('mousemove touchmove', function(evt) {
|
||||
this._onContent('mousemove touchmove', function(evt) {
|
||||
var go = Kinetic.GlobalObject;
|
||||
var node = go.drag.node;
|
||||
if(node) {
|
||||
@ -1986,7 +1981,7 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}, false);
|
||||
|
||||
this.onContent('mouseup touchend mouseout', function(evt) {
|
||||
this._onContent('mouseup touchend mouseout', function(evt) {
|
||||
that._endDrag(evt);
|
||||
});
|
||||
},
|
||||
@ -2064,6 +2059,18 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
_onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Extend Container and Node
|
||||
|
6
dist/kinetic-core.min.js
vendored
6
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
39
src/Stage.js
39
src/Stage.js
@ -1,4 +1,4 @@
|
||||
;///////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Stage
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
@ -274,18 +274,6 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
this._remove(layer);
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* add layer to stage
|
||||
* @param {Layer} layer
|
||||
@ -355,7 +343,7 @@ Kinetic.Stage.prototype = {
|
||||
* @param {Object} point
|
||||
*/
|
||||
getIntersections: function() {
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var arr = [];
|
||||
var shapes = this.get('Shape');
|
||||
|
||||
@ -368,6 +356,13 @@ Kinetic.Stage.prototype = {
|
||||
|
||||
return arr;
|
||||
},
|
||||
/**
|
||||
* get stage DOM node, which is a div element
|
||||
* with the class name "kineticjs-content"
|
||||
*/
|
||||
getDOM: function() {
|
||||
return this.content;
|
||||
},
|
||||
/**
|
||||
* detect event
|
||||
* @param {Shape} shape
|
||||
@ -722,7 +717,7 @@ Kinetic.Stage.prototype = {
|
||||
_prepareDrag: function() {
|
||||
var that = this;
|
||||
|
||||
this.onContent('mousemove touchmove', function(evt) {
|
||||
this._onContent('mousemove touchmove', function(evt) {
|
||||
var go = Kinetic.GlobalObject;
|
||||
var node = go.drag.node;
|
||||
if(node) {
|
||||
@ -784,7 +779,7 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}, false);
|
||||
|
||||
this.onContent('mouseup touchend mouseout', function(evt) {
|
||||
this._onContent('mouseup touchend mouseout', function(evt) {
|
||||
that._endDrag(evt);
|
||||
});
|
||||
},
|
||||
@ -862,6 +857,18 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
_onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Extend Container and Node
|
||||
|
@ -128,6 +128,15 @@ Test.prototype.tests = {
|
||||
test(attrs.name === 'myCircle', 'name attr should be myCircle');
|
||||
test(attrs.draggable === true, 'draggable attr should be true');
|
||||
},
|
||||
'STAGE - get stage DOM': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
|
||||
test(stage.getDOM().className === 'kineticjs-content', 'stage DOM class name is wrong');
|
||||
},
|
||||
'STAGE - load stage using json': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
|
Loading…
Reference in New Issue
Block a user