mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 06:55:17 +08:00
rebuild
This commit is contained in:
parent
2a3cca8efa
commit
a027c0ddf5
87
konva.js
87
konva.js
@ -2,7 +2,7 @@
|
||||
* Konva JavaScript Framework v2.0.2
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT
|
||||
* Date: Wed Mar 21 2018
|
||||
* Date: Sun Mar 25 2018
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||
@ -7771,14 +7771,18 @@
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* return a {@link Konva.Collection} of nodes that match the selector. Use '#' for id selections
|
||||
* and '.' for name selections. You can also select by type or class name. Pass multiple selectors
|
||||
* return a {@link Konva.Collection} of nodes that match the selector.
|
||||
* You can provide a string with '#' for id selections and '.' for name selections.
|
||||
* Or a function that will return true/false when a node is passed through. See example below.
|
||||
* With strings you can also select by type or class name. Pass multiple selectors
|
||||
* separated by a space.
|
||||
* @method
|
||||
* @memberof Konva.Container.prototype
|
||||
* @param {String} selector
|
||||
* @param {String | Function} selector
|
||||
* @returns {Collection}
|
||||
* @example
|
||||
*
|
||||
* Passing a string as a selector
|
||||
* // select node with id foo
|
||||
* var node = stage.find('#foo');
|
||||
*
|
||||
@ -7793,8 +7797,47 @@
|
||||
*
|
||||
* // select node with an id of foo or a name of bar inside layer
|
||||
* var nodes = layer.find('#foo, .bar');
|
||||
*
|
||||
* Passing a function as a selector
|
||||
*
|
||||
* // get all Groups
|
||||
* var groups = stage.find(node => {
|
||||
* return node.getType() === 'Group';
|
||||
* });
|
||||
*
|
||||
* // get only Nodes with partial opacity
|
||||
* var alphaNodes = layer.find(node => {
|
||||
* return node.getType() === 'Node' && node.getAbsoluteOpacity() < 1;
|
||||
* });
|
||||
*/
|
||||
find: function(selector) {
|
||||
var retArr = [];
|
||||
|
||||
if (typeof selector === 'string') {
|
||||
retArr = this._findByString(selector);
|
||||
} else if (typeof selector === 'function') {
|
||||
retArr = this._findByFunction(selector);
|
||||
}
|
||||
|
||||
return Konva.Collection.toCollection(retArr);
|
||||
},
|
||||
/**
|
||||
* return a first node from `find` method
|
||||
* @method
|
||||
* @memberof Konva.Container.prototype
|
||||
* @param {String} selector
|
||||
* @returns {Konva.Node}
|
||||
* @example
|
||||
* // select node with id foo
|
||||
* var node = stage.findOne('#foo');
|
||||
*
|
||||
* // select node with name bar inside layer
|
||||
* var nodes = layer.findOne('.bar');
|
||||
*/
|
||||
findOne: function(selector) {
|
||||
return this.find(selector)[0];
|
||||
},
|
||||
_findByString: function(selector) {
|
||||
var retArr = [],
|
||||
selectorArr = selector.replace(/ /g, '').split(','),
|
||||
len = selectorArr.length,
|
||||
@ -7839,23 +7882,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
return Konva.Collection.toCollection(retArr);
|
||||
return retArr;
|
||||
},
|
||||
/**
|
||||
* return a first node from `find` method
|
||||
* @method
|
||||
* @memberof Konva.Container.prototype
|
||||
* @param {String} selector
|
||||
* @returns {Konva.Node}
|
||||
* @example
|
||||
* // select node with id foo
|
||||
* var node = stage.findOne('#foo');
|
||||
*
|
||||
* // select node with name bar inside layer
|
||||
* var nodes = layer.findOne('.bar');
|
||||
*/
|
||||
findOne: function(selector) {
|
||||
return this.find(selector)[0];
|
||||
_findByFunction: function(fn) {
|
||||
var retArr = [];
|
||||
|
||||
var addItems = function(el) {
|
||||
var children = el.getChildren();
|
||||
var clen = children.length;
|
||||
|
||||
if (fn(el)) {
|
||||
retArr = retArr.concat(el);
|
||||
}
|
||||
|
||||
for (var i = 0; i < clen; i++) {
|
||||
addItems(children[i]);
|
||||
}
|
||||
};
|
||||
|
||||
addItems(this);
|
||||
|
||||
return retArr;
|
||||
},
|
||||
_getNodeById: function(key) {
|
||||
var node = Konva.ids[key];
|
||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user