container selector

This commit is contained in:
ningyi.zny
2016-02-26 22:21:49 +08:00
parent 8b23ae64df
commit 29a48662b4
2 changed files with 255 additions and 235 deletions

View File

@@ -3,7 +3,7 @@
* Konva JavaScript Framework v0.11.1
* http://konvajs.github.io/
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Fri Feb 05 2016
* Date: Fri Feb 26 2016
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
@@ -8659,8 +8659,18 @@
*/
setContainer: function (container) {
if (typeof container === STRING) {
var id = container;
container = Konva.document.getElementById(container);
if (container.charAt(0) === '.') {
var className = container.slice(1);
container = Konva.document.getElementsByClassName(className)[0];
} else {
var id;
if (container.charAt(0) !== '#') {
id = container;
} else {
id = container.slice(1);
}
container = Konva.document.getElementById(id);
}
if (!container) {
throw 'Can not find container in document with id ' + id;
}

View File

@@ -97,8 +97,18 @@
*/
setContainer: function (container) {
if (typeof container === STRING) {
var id = container;
container = Konva.document.getElementById(container);
if (container.charAt(0) === '.') {
var className = container.slice(1);
container = Konva.document.getElementsByClassName(className)[0];
} else {
var id;
if (container.charAt(0) !== '#') {
id = container;
} else {
id = container.slice(1);
}
container = Konva.document.getElementById(id);
}
if (!container) {
throw 'Can not find container in document with id ' + id;
}