@@ -2573,13 +2573,16 @@ const createScatterplot = (initialProperties = {}) => {
25732573 // setWidth and setHeight can be async when width or height are set to
25742574 // 'auto'. And since draw() would have anyway been async we can just make
25752575 // all calls async.
2576- window . requestAnimationFrame ( ( ) => {
2577- if ( ! canvas ) return ; // Instance was destroyed in between
2578- updateViewAspectRatio ( ) ;
2579- refresh ( ) ;
2580- draw ( ) ;
2581- drawHandler ( ) ;
2582- } ) ;
2576+ return new Promise ( ( resolve ) =>
2577+ window . requestAnimationFrame ( ( ) => {
2578+ if ( ! canvas ) return ; // Instance was destroyed in between
2579+ updateViewAspectRatio ( ) ;
2580+ refresh ( ) ;
2581+ draw ( ) ;
2582+ drawHandler ( ) ;
2583+ resolve ( ) ;
2584+ } )
2585+ ) ;
25832586 } ;
25842587
25852588 const hover = ( point , showReticleOnce = false ) => {
@@ -2744,7 +2747,7 @@ const createScatterplot = (initialProperties = {}) => {
27442747 encodingTex = createEncodingTexture ( ) ;
27452748
27462749 // Set dimensions
2747- set ( {
2750+ const whenSet = set ( {
27482751 backgroundImage,
27492752 width,
27502753 height,
@@ -2764,6 +2767,10 @@ const createScatterplot = (initialProperties = {}) => {
27642767 canvas . addEventListener ( 'mouseleave' , mouseLeaveCanvasHandler , false ) ;
27652768 canvas . addEventListener ( 'click' , mouseClickHandler , false ) ;
27662769 canvas . addEventListener ( 'dblclick' , mouseDblClickHandler , false ) ;
2770+
2771+ whenSet . then ( ( ) => {
2772+ pubSub . publish ( 'init' ) ;
2773+ } ) ;
27672774 } ;
27682775
27692776 const destroy = ( ) => {
@@ -2786,6 +2793,7 @@ const createScatterplot = (initialProperties = {}) => {
27862793 pointConnections . destroy ( ) ;
27872794 reticleHLine . destroy ( ) ;
27882795 reticleVLine . destroy ( ) ;
2796+ pubSub . publish ( 'destroy' ) ;
27892797 pubSub . clear ( ) ;
27902798 } ;
27912799
0 commit comments