Structural changes to objects are relatively more expensive and
harder to optimize for modern JavaScript compilers, compared to
just changing object's key values. The parent property of nodes
is already set to null now, as part constructing the object.
Setting it back to null on removal / destroy of objects is more
consistent and a tiny little bit more efficient.
The code was checking the "waiting" flags, but they were not set.
This patch corrects that part and makes a few other tweaks to the
updated logic on top of requestAnimationFrame().
Following the recent migration to TypeScript, getGlobalKonva()
returns undefined (as glob.Konva was not set) when using konva.js
or konva.min.js inside a web application running in a browser.
This change works around the situation by explicitly setting the
Konva property on the glob object.
As the context's translate() is additive, there is no need for
the two consecutive calls of it inside _sceneFunc(): The same
effect can be achieved with with just one call of translate().
A corresponding update was done in the unit test for Text that
had a pair of calls to translate() in the expected call dump.
This is just a minor change to avoid accessing the same property
in object this._cache twice inside _getCache() when its is already
set (defined). No big performance improvements probably, but given
that the cached values can be checked many times for each node
in the tree, I think it makes sense to do that small improvement.
A small improvement to avoid re-testing the presence of underline
and line-through attributes in the textDecoration property on each
line of the text being rendered.
The original Boolean condition duplicates most of the predicates
used in both parts of the "or" expression. It is enough to test
them just once, which also makes it easier to figure out what
the criterion for using the buffer canvas is. (An extra effect
is that the code becomes smaller and potentially quicker for the
JIT compiler to handle, but I don't expect much reduction here.)
This is just a minor improvement (optimization) to _setTextData():
Flag shouldAddEllipsis is not changed inside the loop, thus no need
to recalculate the value of additionalWidth for every line of the
original text.
Similar to how it's handled in getWidth() and getHeight() of Konva.Text,
let _setTextData() treat undefined values of the 'width' and 'height'
attributes as if they are set to 'auto', not as if they are fixed.
- remove check for mobile flag in mouse event handlers
- remove workaround fake mousemove event in chrome browser https://code.google.com/p/chromium/issues/detail?id=161464 because it prevents mouse events working on Android mobile devices