diff --git a/CHANGELOG.md b/CHANGELOG.md index f213411d..8c02e048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [new version][unreleased] +## [2.1.4][2018-06-15] + ## Fixed * Fixed `Konva.Text` justify drawing for a text with decoration * Added methods `data()`,`setData()` and `getData()` methods to `Konva.TextPath` - +* Correct cache reset for `Konva.Transformer` ## [2.1.3][2018-05-17] diff --git a/konva.js b/konva.js index 382ce567..c4d27100 100644 --- a/konva.js +++ b/konva.js @@ -2,7 +2,7 @@ * Konva JavaScript Framework v2.1.3 * http://konvajs.github.io/ * Licensed under the MIT - * Date: Tue Jun 05 2018 + * Date: Fri Jun 15 2018 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) @@ -18879,7 +18879,7 @@ this.detach(); } this._node = node; - this._clearCache(NODE_RECT); + this._resetTransformCache(); node.on(TRANSFORM_CHANGE_STR, this._resetTransformCache.bind(this)); node.on( diff --git a/konva.min.js b/konva.min.js index 96a77bdd..eef8612e 100644 --- a/konva.min.js +++ b/konva.min.js @@ -2,7 +2,7 @@ * Konva JavaScript Framework v2.1.3 * http://konvajs.github.io/ * Licensed under the MIT - * Date: Tue Jun 05 2018 + * Date: Fri Jun 15 2018 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) @@ -23,4 +23,4 @@ * @example * node.cache(); * node.filters([Konva.Filters.Sepia]); - */Konva.Filters.Sepia=function(t){var e,n,i,a,r,o,s,h,c,l=t.data,d=t.width,u=t.height,f=4*d;do{for(e=(u-1)*f,n=d;s=.393*(a=l[i=e+4*(n-1)])+.769*(r=l[i+1])+.189*(o=l[i+2]),h=.349*a+.686*r+.168*o,c=.272*a+.534*r+.131*o,l[i]=255this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())},getTime:function(){return this._time},setPosition:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t},getPosition:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)},play:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)},pause:function(){this.state=1,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Konva.Tween=function(t){var e,n,i=this,a=t.node,r=a._id,o=t.easing||Konva.Easings.Linear,s=!!t.yoyo;e=void 0===t.duration?1:0===t.duration?.001:t.duration,this.node=a,this._id=l++;var h=a.getLayer()||(a instanceof Konva.Stage?a.getLayers():null);for(n in h||Konva.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Konva.Animation(function(){i.tween.onEnterFrame()},h),this.tween=new d(n,function(t){i._tweenFunc(t)},o,0,1,1e3*e,s),this._addListeners(),Konva.Tween.attrs[r]||(Konva.Tween.attrs[r]={}),Konva.Tween.attrs[r][this._id]||(Konva.Tween.attrs[r][this._id]={}),Konva.Tween.tweens[r]||(Konva.Tween.tweens[r]={}),t)void 0===c[n]&&this._addAttr(n,t[n]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset},Konva.Tween.attrs={},Konva.Tween.tweens={},Konva.Tween.prototype={_addAttr:function(t,e){var n,i,a,r,o,s,h,c=this.node,l=c._id;if((a=Konva.Tween.tweens[l][t])&&delete Konva.Tween.attrs[l][a][t],n=c.getAttr(t),Konva.Util._isArray(e))for(i=[],o=Math.max(e.length,n.length),"points"===t&&e.length!==n.length&&(e.length>n.length?(h=n,n=Konva.Util._prepareArrayForTween(n,e,c.closed())):(s=e,e=Konva.Util._prepareArrayForTween(e,n,c.closed()))),r=0;r>>1,F=_.slice(0,w+1),T=this._getTextWidth(F)+y;T<=c?(K=w+1,C=F+(v?"…":""),b=T):x=w}if(!C)break;if(g){var P,A=_[C.length];0<(P=(" "===A||"-"===A)&&b<=c?C.length:Math.max(C.lastIndexOf(" "),C.lastIndexOf("-"))+1)&&(K=P,C=C.slice(0,K),b=this._getTextWidth(C))}if(this._addTextLine(C),n=Math.max(n,b),d+=i,!f||s&&le?v=Konva.Path.getPointOnLine(e,g.x,g.y,p.points[0],p.points[1],g.x,g.y):p=void 0;break;case"A":var o=p.points[4],s=p.points[5],h=p.points[4]+s;0===_?_=o+1e-8:np.pathLength?1e-8:e/p.pathLength:nthis.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())},getTime:function(){return this._time},setPosition:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t},getPosition:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)},play:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)},pause:function(){this.state=1,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Konva.Tween=function(t){var e,n,i=this,a=t.node,r=a._id,o=t.easing||Konva.Easings.Linear,s=!!t.yoyo;e=void 0===t.duration?1:0===t.duration?.001:t.duration,this.node=a,this._id=l++;var h=a.getLayer()||(a instanceof Konva.Stage?a.getLayers():null);for(n in h||Konva.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Konva.Animation(function(){i.tween.onEnterFrame()},h),this.tween=new d(n,function(t){i._tweenFunc(t)},o,0,1,1e3*e,s),this._addListeners(),Konva.Tween.attrs[r]||(Konva.Tween.attrs[r]={}),Konva.Tween.attrs[r][this._id]||(Konva.Tween.attrs[r][this._id]={}),Konva.Tween.tweens[r]||(Konva.Tween.tweens[r]={}),t)void 0===c[n]&&this._addAttr(n,t[n]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset},Konva.Tween.attrs={},Konva.Tween.tweens={},Konva.Tween.prototype={_addAttr:function(t,e){var n,i,a,r,o,s,h,c=this.node,l=c._id;if((a=Konva.Tween.tweens[l][t])&&delete Konva.Tween.attrs[l][a][t],n=c.getAttr(t),Konva.Util._isArray(e))for(i=[],o=Math.max(e.length,n.length),"points"===t&&e.length!==n.length&&(e.length>n.length?(h=n,n=Konva.Util._prepareArrayForTween(n,e,c.closed())):(s=e,e=Konva.Util._prepareArrayForTween(e,n,c.closed()))),r=0;r>>1,F=_.slice(0,w+1),T=this._getTextWidth(F)+y;T<=c?(K=w+1,C=F+(v?"…":""),b=T):x=w}if(!C)break;if(g){var P,A=_[C.length];0<(P=(" "===A||"-"===A)&&b<=c?C.length:Math.max(C.lastIndexOf(" "),C.lastIndexOf("-"))+1)&&(K=P,C=C.slice(0,K),b=this._getTextWidth(C))}if(this._addTextLine(C),n=Math.max(n,b),d+=i,!f||s&&le?v=Konva.Path.getPointOnLine(e,g.x,g.y,p.points[0],p.points[1],g.x,g.y):p=void 0;break;case"A":var o=p.points[4],s=p.points[5],h=p.points[4]+s;0===_?_=o+1e-8:np.pathLength?1e-8:e/p.pathLength:n