mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
update changelog, make a build
This commit is contained in:
parent
06b633fd49
commit
7a3cebab6e
@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
* Fixed flow for `contextmenu` event. Not it will be triggered on shapes too
|
* Fixed flow for `contextmenu` event. Not it will be triggered on shapes too
|
||||||
|
* `find()` method for Containers can use a function as a parameter
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
122
konva.js
122
konva.js
@ -2,7 +2,7 @@
|
|||||||
* Konva JavaScript Framework v2.0.2
|
* Konva JavaScript Framework v2.0.2
|
||||||
* http://konvajs.github.io/
|
* http://konvajs.github.io/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Wed Mar 21 2018
|
* Date: Thu Mar 29 2018
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
@ -7762,14 +7762,18 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* return a {@link Konva.Collection} of nodes that match the selector. Use '#' for id selections
|
* return a {@link Konva.Collection} of nodes that match the selector.
|
||||||
* and '.' for name selections. You can also select by type or class name. Pass multiple selectors
|
* 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.
|
* separated by a space.
|
||||||
* @method
|
* @method
|
||||||
* @memberof Konva.Container.prototype
|
* @memberof Konva.Container.prototype
|
||||||
* @param {String} selector
|
* @param {String | Function} selector
|
||||||
* @returns {Collection}
|
* @returns {Collection}
|
||||||
* @example
|
* @example
|
||||||
|
*
|
||||||
|
* Passing a string as a selector
|
||||||
* // select node with id foo
|
* // select node with id foo
|
||||||
* var node = stage.find('#foo');
|
* var node = stage.find('#foo');
|
||||||
*
|
*
|
||||||
@ -7784,8 +7788,58 @@
|
|||||||
*
|
*
|
||||||
* // select node with an id of foo or a name of bar inside layer
|
* // select node with an id of foo or a name of bar inside layer
|
||||||
* var nodes = layer.find('#foo, .bar');
|
* 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) {
|
find: function(selector) {
|
||||||
|
// protecting _generalFind to prevent user from accidentally adding
|
||||||
|
// second argument and getting unexpected `findOne` result
|
||||||
|
return this._generalFind(selector, false);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* return a first node from `find` method
|
||||||
|
* @method
|
||||||
|
* @memberof Konva.Container.prototype
|
||||||
|
* @param {String | Function} selector
|
||||||
|
* @returns {Konva.Node | Undefined}
|
||||||
|
* @example
|
||||||
|
* // select node with id foo
|
||||||
|
* var node = stage.findOne('#foo');
|
||||||
|
*
|
||||||
|
* // select node with name bar inside layer
|
||||||
|
* var nodes = layer.findOne('.bar');
|
||||||
|
*
|
||||||
|
* // select the first node to return true in a function
|
||||||
|
* var node = stage.findOne(node => {
|
||||||
|
* return node.getType() === 'Shape'
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
findOne: function(selector) {
|
||||||
|
var result = this._generalFind(selector, true);
|
||||||
|
return result.length > 0 ? result[0] : undefined;
|
||||||
|
},
|
||||||
|
_generalFind: function(selector, findOne) {
|
||||||
|
var retArr = [];
|
||||||
|
|
||||||
|
if (typeof selector === 'string') {
|
||||||
|
retArr = this._findByString(selector, findOne);
|
||||||
|
} else if (typeof selector === 'function') {
|
||||||
|
retArr = this._findByFunction(selector, findOne);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Konva.Collection.toCollection(retArr);
|
||||||
|
},
|
||||||
|
_findByString: function(selector) {
|
||||||
var retArr = [],
|
var retArr = [],
|
||||||
selectorArr = selector.replace(/ /g, '').split(','),
|
selectorArr = selector.replace(/ /g, '').split(','),
|
||||||
len = selectorArr.length,
|
len = selectorArr.length,
|
||||||
@ -7830,23 +7884,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Konva.Collection.toCollection(retArr);
|
return retArr;
|
||||||
},
|
},
|
||||||
/**
|
// (fn: ((Node) => boolean, findOne?: boolean)
|
||||||
* return a first node from `find` method
|
_findByFunction: function(fn, findOne) {
|
||||||
* @method
|
var retArr = [];
|
||||||
* @memberof Konva.Container.prototype
|
|
||||||
* @param {String} selector
|
var addItems = function(el) {
|
||||||
* @returns {Konva.Node}
|
// escape function if we've already found one.
|
||||||
* @example
|
if (findOne && retArr.length > 0) {
|
||||||
* // select node with id foo
|
return;
|
||||||
* var node = stage.findOne('#foo');
|
}
|
||||||
*
|
|
||||||
* // select node with name bar inside layer
|
var children = el.getChildren();
|
||||||
* var nodes = layer.findOne('.bar');
|
var clen = children.length;
|
||||||
*/
|
|
||||||
findOne: function(selector) {
|
if (fn(el)) {
|
||||||
return this.find(selector)[0];
|
retArr = retArr.concat(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < clen; i++) {
|
||||||
|
addItems(children[i]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addItems(this);
|
||||||
|
|
||||||
|
return retArr;
|
||||||
},
|
},
|
||||||
_getNodeById: function(key) {
|
_getNodeById: function(key) {
|
||||||
var node = Konva.ids[key];
|
var node = Konva.ids[key];
|
||||||
@ -14840,14 +14904,14 @@
|
|||||||
var lineWidth = this._getTextWidth(line);
|
var lineWidth = this._getTextWidth(line);
|
||||||
if (fixedWidth && lineWidth > maxWidth) {
|
if (fixedWidth && lineWidth > maxWidth) {
|
||||||
/*
|
/*
|
||||||
* if width is fixed and line does not fit entirely
|
* if width is fixed and line does not fit entirely
|
||||||
* break the line into multiple fitting lines
|
* break the line into multiple fitting lines
|
||||||
*/
|
*/
|
||||||
while (line.length > 0) {
|
while (line.length > 0) {
|
||||||
/*
|
/*
|
||||||
* use binary search to find the longest substring that
|
* use binary search to find the longest substring that
|
||||||
* that would fit in the specified width
|
* that would fit in the specified width
|
||||||
*/
|
*/
|
||||||
var low = 0,
|
var low = 0,
|
||||||
high = line.length,
|
high = line.length,
|
||||||
match = '',
|
match = '',
|
||||||
@ -14891,9 +14955,9 @@
|
|||||||
(fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx)
|
(fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx)
|
||||||
) {
|
) {
|
||||||
/*
|
/*
|
||||||
* stop wrapping if wrapping is disabled or if adding
|
* stop wrapping if wrapping is disabled or if adding
|
||||||
* one more line would overflow the fixed height
|
* one more line would overflow the fixed height
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
line = line.slice(low);
|
line = line.slice(low);
|
||||||
|
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