@@ -292,12 +292,17 @@ export class Ripple extends LitElement implements Attachable {
292292 SOFT_EDGE_MINIMUM_SIZE ,
293293 ) ;
294294
295- const initialSize = Math . floor ( maxDim * INITIAL_ORIGIN_SCALE ) ;
295+ // `?? 1` may be removed once `currentCSSZoom` is widely available.
296+ const zoom = this . currentCSSZoom ?? 1 ;
297+ const initialSize = Math . floor ( ( maxDim * INITIAL_ORIGIN_SCALE ) / zoom ) ;
296298 const hypotenuse = Math . sqrt ( width ** 2 + height ** 2 ) ;
297299 const maxRadius = hypotenuse + PADDING ;
298300
299301 this . initialSize = initialSize ;
300- this . rippleScale = `${ ( maxRadius + softEdgeSize ) / initialSize } ` ;
302+ // The dimensions may be altered by CSS `zoom`, which needs to be
303+ // compensated for in the final scale() value.
304+ const maybeZoomedScale = ( maxRadius + softEdgeSize ) / initialSize ;
305+ this . rippleScale = `${ maybeZoomedScale / zoom } ` ;
301306 this . rippleSize = `${ initialSize } px` ;
302307 }
303308
@@ -310,24 +315,31 @@ export class Ripple extends LitElement implements Attachable {
310315 const documentX = scrollX + left ;
311316 const documentY = scrollY + top ;
312317 const { pageX, pageY} = pointerEvent ;
313- return { x : pageX - documentX , y : pageY - documentY } ;
318+ // `?? 1` may be removed once `currentCSSZoom` is widely available.
319+ const zoom = this . currentCSSZoom ?? 1 ;
320+ return {
321+ x : ( pageX - documentX ) / zoom ,
322+ y : ( pageY - documentY ) / zoom ,
323+ } ;
314324 }
315325
316326 private getTranslationCoordinates ( positionEvent ?: Event ) {
317327 const { height, width} = this . getBoundingClientRect ( ) ;
328+ // `?? 1` may be removed once `currentCSSZoom` is widely available.
329+ const zoom = this . currentCSSZoom ?? 1 ;
318330 // end in the center
319331 const endPoint = {
320- x : ( width - this . initialSize ) / 2 ,
321- y : ( height - this . initialSize ) / 2 ,
332+ x : ( width / zoom - this . initialSize ) / 2 ,
333+ y : ( height / zoom - this . initialSize ) / 2 ,
322334 } ;
323335
324336 let startPoint ;
325337 if ( positionEvent instanceof PointerEvent ) {
326338 startPoint = this . getNormalizedPointerEventCoords ( positionEvent ) ;
327339 } else {
328340 startPoint = {
329- x : width / 2 ,
330- y : height / 2 ,
341+ x : width / zoom / 2 ,
342+ y : height / zoom / 2 ,
331343 } ;
332344 }
333345
0 commit comments