@@ -90,18 +90,27 @@ export class Canvas {
9090 private _postDrawUpdaters : IParticleUpdater [ ] ;
9191 private _preDrawUpdaters : IParticleUpdater [ ] ;
9292 private _resizePlugins : IContainerPlugin [ ] ;
93+ private readonly _standardSize : IDimension ;
9394 private _trailFill ?: ITrailFillData ;
9495
9596 /**
9697 * Constructor of canvas manager
9798 * @param container - the parent container
9899 */
99100 constructor ( private readonly container : Container ) {
100- this . size = {
101+ this . _standardSize = {
101102 height : 0 ,
102103 width : 0 ,
103104 } ;
104105
106+ const pxRatio = container . retina . pixelRatio ,
107+ stdSize = this . _standardSize ;
108+
109+ this . size = {
110+ height : stdSize . height * pxRatio ,
111+ width : stdSize . width * pxRatio ,
112+ } ;
113+
105114 this . _context = null ;
106115 this . _generated = false ;
107116 this . _preDrawUpdaters = [ ] ;
@@ -395,8 +404,14 @@ export class Canvas {
395404 this . element = canvas ;
396405 this . element . ariaHidden = "true" ;
397406 this . _originalStyle = deepExtend ( { } , this . element . style ) as Record < string , string | null > ;
398- this . size . height = canvas . offsetHeight ;
399- this . size . width = canvas . offsetWidth ;
407+ this . _standardSize . height = canvas . offsetHeight ;
408+ this . _standardSize . width = canvas . offsetWidth ;
409+
410+ const pxRatio = this . container . retina . pixelRatio ;
411+
412+ this . size . height = this . _standardSize . height * pxRatio ;
413+ this . size . width = this . _standardSize . width * pxRatio ;
414+
400415 this . _context = this . element . getContext ( "2d" ) ;
401416
402417 this . _safeMutationObserver ( obs => {
@@ -444,26 +459,24 @@ export class Canvas {
444459 }
445460
446461 const container = this . container ,
447- pxRatio = container . retina . pixelRatio ,
448- size = container . canvas . size ,
462+ size = container . canvas . _standardSize ,
449463 newSize = {
450- width : this . element . offsetWidth * pxRatio ,
451- height : this . element . offsetHeight * pxRatio ,
464+ width : this . element . offsetWidth ,
465+ height : this . element . offsetHeight ,
452466 } ;
453467
454- if (
455- newSize . height === size . height &&
456- newSize . width === size . width &&
457- newSize . height === this . element . height &&
458- newSize . width === this . element . width
459- ) {
468+ if ( newSize . height === size . height && newSize . width === size . width ) {
460469 return false ;
461470 }
462471
463- const oldSize = { ...size } ;
472+ const oldSize = { ...size } ,
473+ pxRatio = container . retina . pixelRatio ;
474+
475+ this . _standardSize . height = newSize . height ;
476+ this . _standardSize . width = newSize . width ;
464477
465- this . element . width = size . width = this . element . offsetWidth * pxRatio ;
466- this . element . height = size . height = this . element . offsetHeight * pxRatio ;
478+ this . element . width = this . size . width = this . _standardSize . width * pxRatio ;
479+ this . element . height = this . size . height = this . _standardSize . height * pxRatio ;
467480
468481 if ( this . container . started ) {
469482 container . particles . setResizeFactor ( {
0 commit comments