11import * as d3 from "d3" ; // transitions and other stuff
2+ import { transform } from "../../transform" ;
3+ import { easeCubicInOut } from "d3-ease" ;
24import { rotatePointAboutPoint } from "../../geom" ;
35import { svgns } from "../../svgns" ;
46import { Interactor } from "./interactor" ;
@@ -45,8 +47,8 @@ export class Polymer extends Interactor {
4547 scale ( ) {
4648 const protLength = ( this . size ) * this . stickZoom ;
4749 if ( this . expanded ) {
48- const labelTransform = d3 . transform ( this . labelSVG . getAttribute ( "transform" ) ) ;
49- const k = this . app . svgElement . createSVGMatrix ( ) . rotate ( labelTransform . rotate )
50+ const labelTransform = transform ( this . labelSVG . getAttribute ( "transform" ) ) ;
51+ const k = this . app . svgElement . createSVGMatrix ( )
5052 . translate ( ( - ( ( ( this . size / 2 ) * this . stickZoom ) + ( this . nTermFeatures . length > 0 ? 25 : 10 ) ) ) , this . labelY ) ; //.scale(z).translate(-c.x, -c.y);
5153 this . labelSVG . transform . baseVal . initialize ( this . app . svgElement . createSVGTransformFromMatrix ( k ) ) ;
5254 this . updateAnnotationRectanglesNoTransition ( ) ;
@@ -159,7 +161,6 @@ export class Polymer extends Interactor {
159161 }
160162
161163 toCircle ( transition = true , svgP ) {
162-
163164 if ( ! svgP ) {
164165 const width = this . app . svgElement . parentNode . clientWidth ;
165166 const ctm = this . app . container . getCTM ( ) . inverse ( ) ;
@@ -196,7 +197,7 @@ export class Polymer extends Interactor {
196197 . duration ( transitionTime ) ;
197198
198199 const stickZoomInterpol = d3 . interpolate ( this . stickZoom , 0 ) ;
199- const labelTransform = d3 . transform ( this . labelSVG . getAttribute ( "transform" ) ) ;
200+ const labelTransform = transform ( this . labelSVG . getAttribute ( "transform" ) ) ;
200201 const labelStartPoint = labelTransform . translate [ 0 ] ;
201202 const labelTranslateInterpol = d3 . interpolate ( labelStartPoint , - ( r + 5 ) ) ;
202203
@@ -209,15 +210,15 @@ export class Polymer extends Interactor {
209210
210211 const self = this ;
211212 d3 . select ( this . ticks ) . transition ( ) . attr ( "opacity" , 0 ) . duration ( transitionTime / 4 )
212- . each ( "end" ,
213+ . on ( "end" ,
213214 function ( ) {
214215 d3 . select ( this ) . selectAll ( "*" ) . remove ( ) ;
215216 }
216217 ) ;
217218
218219 const originalStickZoom = this . stickZoom ;
219220 const originalRotation = this . rotation ;
220- const cubicInOut = d3 . ease ( "cubic-in-out" ) ;
221+ const cubicInOut = easeCubicInOut ;
221222 if ( transition ) {
222223 for ( let [ annotationType , annotations ] of this . annotationSets ) {
223224 if ( this . app . annotationSetsShown . get ( annotationType ) === true ) {
@@ -242,16 +243,15 @@ export class Polymer extends Interactor {
242243 }
243244 }
244245 }
245- d3 . timer ( function ( elapsed ) {
246- return update ( elapsed / transitionTime ) ;
246+ const t = d3 . timer ( function ( elapsed ) {
247+ if ( update ( elapsed / transitionTime ) ) t . stop ( ) ;
247248 } ) ;
248249 } else {
249250 update ( 1 ) ;
250251 }
251252
252253 function update ( interp ) {
253- const labelTransform = d3 . transform ( self . labelSVG . getAttribute ( "transform" ) ) ;
254- const k = self . app . svgElement . createSVGMatrix ( ) . rotate ( labelTransform . rotate ) . translate ( labelTranslateInterpol ( cubicInOut ( interp ) ) , self . labelY ) ; //.scale(z).translate(-c.x, -c.y);
254+ const k = self . app . svgElement . createSVGMatrix ( ) . translate ( labelTranslateInterpol ( cubicInOut ( interp ) ) , self . labelY ) ; //.scale(z).translate(-c.x, -c.y);
255255 self . labelSVG . transform . baseVal . initialize ( self . app . svgElement . createSVGTransformFromMatrix ( k ) ) ;
256256
257257 if ( xInterpol !== null ) {
@@ -339,7 +339,7 @@ export class Polymer extends Interactor {
339339
340340
341341 const self = this ;
342- const cubicInOut = d3 . ease ( "cubic-in-out" ) ;
342+ const cubicInOut = easeCubicInOut ;
343343 if ( transition ) {
344344 for ( let [ annotationType , annotations ] of this . annotationSets ) {
345345 if ( this . app . annotationSetsShown . get ( annotationType ) === true ) {
@@ -374,16 +374,16 @@ export class Polymer extends Interactor {
374374 }
375375 }
376376 }
377- d3 . timer ( function ( elapsed ) {
378- return update ( elapsed / transitionTime ) ;
377+ const t = d3 . timer ( function ( elapsed ) {
378+ if ( update ( elapsed / transitionTime ) ) t . stop ( ) ;
379379 } ) ;
380380 } else {
381381 update ( 1 ) ;
382382 }
383383
384384 function update ( interp ) {
385- const labelTransform = d3 . transform ( self . labelSVG . getAttribute ( "transform" ) ) ;
386- const k = self . app . svgElement . createSVGMatrix ( ) . rotate ( labelTransform . rotate ) . translate ( labelTranslateInterpol ( cubicInOut ( interp ) ) , self . labelY ) ; //.scale(z).translate(-c.x, -c.y);
385+ const labelTransform = transform ( self . labelSVG . getAttribute ( "transform" ) ) ;
386+ const k = self . app . svgElement . createSVGMatrix ( ) . rotate ( labelTransform . rotate ) . translate ( labelTranslateInterpol ( cubicInOut ( interp ) ) , self . labelY )
387387 self . labelSVG . transform . baseVal . initialize ( self . app . svgElement . createSVGTransformFromMatrix ( k ) ) ;
388388
389389 const currentLength = lengthInterpol ( cubicInOut ( interp ) ) ;
0 commit comments