@ -16,7 +16,6 @@ class CanvasRenderer {
this . requiresTimeout = true ;
this . requiresTimeout = true ;
this . renderingActive = false ;
this . renderingActive = false ;
this . renderRequests = 0 ;
this . renderRequests = 0 ;
this . pixelRatio = undefined ;
this . allowRedraw = true ;
this . allowRedraw = true ;
this . dragging = false ;
this . dragging = false ;
@ -138,20 +137,15 @@ class CanvasRenderer {
this . body . emitter . emit ( "initRedraw" ) ;
this . body . emitter . emit ( "initRedraw" ) ;
this . redrawRequested = false ;
this . redrawRequested = false ;
let ctx = this . canvas . frame . canvas . getContext ( '2d' ) ;
// when the container div was hidden, this fixes it back up!
// when the container div was hidden, this fixes it back up!
if ( this . canvas . frame . canvas . width === 0 || this . canvas . frame . canvas . height === 0 ) {
if ( this . canvas . frame . canvas . width === 0 || this . canvas . frame . canvas . height === 0 ) {
this . canvas . setSize ( ) ;
this . canvas . setSize ( ) ;
}
}
this . pixelRatio = ( window . devicePixelRatio || 1 ) / ( ctx . webkitBackingStorePixelRatio ||
ctx . mozBackingStorePixelRatio ||
ctx . msBackingStorePixelRatio ||
ctx . oBackingStorePixelRatio ||
ctx . backingStorePixelRatio || 1 ) ;
this . canvas . setTransform ( ) ;
ctx . setTransform ( this . pixelRatio , 0 , 0 , this . pixelRatio , 0 , 0 ) ;
let ctx = this . canvas . getContext ( ) ;
// clear the canvas
// clear the canvas
let w = this . canvas . frame . canvas . clientWidth ;
let w = this . canvas . frame . canvas . clientWidth ;
@ -198,21 +192,14 @@ class CanvasRenderer {
/ * *
/ * *
* Redraw all nodes
* Redraw all nodes
* The 2 d context of a HTML canvas can be retrieved by canvas . getContext ( '2d' ) ;
*
* @ param { CanvasRenderingContext2D } ctx
* @ param { CanvasRenderingContext2D } ctx
* @ param { Boolean } [ alwaysShow ]
* @ param { Boolean } [ alwaysShow ]
* @ private
* @ private
* /
* /
_resizeNodes ( ) {
_resizeNodes ( ) {
let ctx = this . canvas . frame . canvas . getContext ( '2d' ) ;
if ( this . pixelRatio === undefined ) {
this . pixelRatio = ( window . devicePixelRatio || 1 ) / ( ctx . webkitBackingStorePixelRatio ||
ctx . mozBackingStorePixelRatio ||
ctx . msBackingStorePixelRatio ||
ctx . oBackingStorePixelRatio ||
ctx . backingStorePixelRatio || 1 ) ;
}
ctx . setTransform ( this . pixelRatio , 0 , 0 , this . pixelRatio , 0 , 0 ) ;
this . canvas . setTransform ( ) ;
let ctx = this . canvas . getContext ( ) ;
ctx . save ( ) ;
ctx . save ( ) ;
ctx . translate ( this . body . view . translation . x , this . body . view . translation . y ) ;
ctx . translate ( this . body . view . translation . x , this . body . view . translation . y ) ;
ctx . scale ( this . body . view . scale , this . body . view . scale ) ;
ctx . scale ( this . body . view . scale , this . body . view . scale ) ;
@ -235,8 +222,8 @@ class CanvasRenderer {
/ * *
/ * *
* Redraw all nodes
* Redraw all nodes
* The 2 d context of a HTML canvas can be retrieved by canvas . getContext ( '2d' ) ;
* @ param { CanvasRenderingContext2D } ctx
*
* @ param { CanvasRenderingContext2D } ctx 2 D con te xt of a HTML canvas
* @ param { Boolean } [ alwaysShow ]
* @ param { Boolean } [ alwaysShow ]
* @ private
* @ private
* /
* /
@ -283,8 +270,7 @@ class CanvasRenderer {
/ * *
/ * *
* Redraw all edges
* Redraw all edges
* The 2 d context of a HTML canvas can be retrieved by canvas . getContext ( '2d' ) ;
* @ param { CanvasRenderingContext2D } ctx
* @ param { CanvasRenderingContext2D } ctx 2 D context of a HTML canvas
* @ private
* @ private
* /
* /
_drawEdges ( ctx ) {
_drawEdges ( ctx ) {