@@ -24,7 +24,7 @@ type Bounds = {
2424 height : number ,
2525} | null ;
2626
27- type BoundPair = {
27+ type SvgBoundsInfo = {
2828 before : Bounds ,
2929 after : Bounds ,
3030} ;
@@ -64,14 +64,14 @@ function getDefaultSvgBoundsIfUndefined(text: string, src: string): Bounds | nul
6464 return null ;
6565}
6666
67- function createContext ( imageAfter : HTMLImageElement , imageBefore : HTMLImageElement , boundPair : BoundPair ) : ImageContext {
67+ function createContext ( imageAfter : HTMLImageElement , imageBefore : HTMLImageElement , svgBoundsInfo : SvgBoundsInfo ) : ImageContext {
6868 const sizeAfter = {
69- width : boundPair . after ?. width || imageAfter ?. width || 0 ,
70- height : boundPair . after ?. height || imageAfter ?. height || 0 ,
69+ width : svgBoundsInfo . after ?. width || imageAfter ?. width || 0 ,
70+ height : svgBoundsInfo . after ?. height || imageAfter ?. height || 0 ,
7171 } ;
7272 const sizeBefore = {
73- width : boundPair . before ?. width || imageBefore ?. width || 0 ,
74- height : boundPair . before ?. height || imageBefore ?. height || 0 ,
73+ width : svgBoundsInfo . before ?. width || imageBefore ?. width || 0 ,
74+ height : svgBoundsInfo . before ?. height || imageBefore ?. height || 0 ,
7575 } ;
7676 const maxSize = {
7777 width : Math . max ( sizeBefore . width , sizeAfter . width ) ,
@@ -118,7 +118,7 @@ class ImageDiff {
118118 boundsInfo : containerEl . querySelector ( '.bounds-info-before' ) ,
119119 } ] ;
120120
121- const boundPair : BoundPair = { before : null , after : null } ;
121+ const svgBoundsInfo : SvgBoundsInfo = { before : null , after : null } ;
122122 await Promise . all ( imagePair . map ( async ( info , index ) => {
123123 const [ success ] = await Promise . all ( Array . from ( info . images , ( img ) => {
124124 return loadElem ( img , info . path ! ) ;
@@ -129,7 +129,7 @@ class ImageDiff {
129129 const resp = await GET ( info . path ! ) ;
130130 const text = await resp . text ( ) ;
131131 const bounds = getDefaultSvgBoundsIfUndefined ( text , info . path ! ) ;
132- boundPair [ index === 0 ? 'after' : 'before' ] = bounds ;
132+ svgBoundsInfo [ index === 0 ? 'after' : 'before' ] = bounds ;
133133 if ( bounds ) {
134134 hideElem ( info . boundsInfo ! ) ;
135135 }
@@ -139,10 +139,10 @@ class ImageDiff {
139139 const imagesAfter = imagePair [ 0 ] . images ;
140140 const imagesBefore = imagePair [ 1 ] . images ;
141141
142- this . initSideBySide ( createContext ( imagesAfter [ 0 ] , imagesBefore [ 0 ] , boundPair ) ) ;
142+ this . initSideBySide ( createContext ( imagesAfter [ 0 ] , imagesBefore [ 0 ] , svgBoundsInfo ) ) ;
143143 if ( imagesAfter . length > 0 && imagesBefore . length > 0 ) {
144- this . initSwipe ( createContext ( imagesAfter [ 1 ] , imagesBefore [ 1 ] , boundPair ) ) ;
145- this . initOverlay ( createContext ( imagesAfter [ 2 ] , imagesBefore [ 2 ] , boundPair ) ) ;
144+ this . initSwipe ( createContext ( imagesAfter [ 1 ] , imagesBefore [ 1 ] , svgBoundsInfo ) ) ;
145+ this . initOverlay ( createContext ( imagesAfter [ 2 ] , imagesBefore [ 2 ] , svgBoundsInfo ) ) ;
146146 }
147147 queryElemChildren ( containerEl , '.image-diff-tabs' , ( el ) => el . classList . remove ( 'is-loading' ) ) ;
148148 }
0 commit comments