@@ -146,11 +146,6 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
146146 const [ src , coords = '' ] = ( cue . text || '' ) . split ( '#' ) ;
147147 this . $state . coords . set ( this . _resolveThumbnailCoords ( coords ) ) ;
148148
149- if ( ! peek ( this . $state . coords ) ) {
150- this . _resetStyles ( ) ;
151- return ;
152- }
153-
154149 this . $state . src . set ( this . _resolveThumbnailSrc ( src , baseURL ) ) ;
155150 this . _requestResize ( ) ;
156151 }
@@ -179,9 +174,10 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
179174 const img = this . $state . img ( ) ,
180175 coords = this . $state . coords ( ) ;
181176
182- if ( ! img || ! coords || ! this . el ) return ;
177+ if ( ! img || ! this . el ) return ;
183178
184- const { w, h, x, y } = coords ,
179+ const w = coords ?. w ?? img . naturalWidth ,
180+ h = coords ?. h ?? img . naturalHeight ,
185181 { maxWidth, maxHeight, minWidth, minHeight } = getComputedStyle ( this . el ) ,
186182 minRatio = Math . max ( parseInt ( minWidth ) / w , parseInt ( minHeight ) / h ) ,
187183 maxRatio = Math . min ( parseInt ( maxWidth ) / w , parseInt ( maxHeight ) / h ) ,
@@ -191,7 +187,11 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
191187 this . _style ( this . el ! , '--thumbnail-height' , `${ h * scale } px` ) ;
192188 this . _style ( img , 'width' , `${ img . naturalWidth * scale } px` ) ;
193189 this . _style ( img , 'height' , `${ img . naturalHeight * scale } px` ) ;
194- this . _style ( img , 'transform' , `translate(-${ x * scale } px, -${ y * scale } px)` ) ;
190+ this . _style (
191+ img ,
192+ 'transform' ,
193+ coords ? `translate(-${ coords . x * scale } px, -${ coords . y * scale } px)` : '' ,
194+ ) ;
195195 this . _style ( img , 'max-width' , 'none' ) ;
196196 }
197197
0 commit comments