@material/web 1.1.2-nightly.ad52075.0 → 1.1.2-nightly.cef1b74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@material/web",
3
- "version": "1.1.2-nightly.ad52075.0",
3
+ "version": "1.1.2-nightly.cef1b74.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -308,6 +308,7 @@ export class Ripple extends LitElement {
308
308
  });
309
309
  }
310
310
  async endPressAnimation() {
311
+ this.rippleStartEvent = undefined;
311
312
  this.state = State.INACTIVE;
312
313
  const animation = this.growAnimation;
313
314
  let pressAnimationPlayState = Infinity;
@@ -1 +1 @@
1
- {"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAEL,oBAAoB,GACrB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAC,MAAM,EAAC,MAAM,oCAAoC,CAAC;AAE1D,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;;;;;;;GASG;AACH,IAAK,KAiCJ;AAjCD,WAAK,KAAK;IACR;;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AC,KAAqB,CAAC,CAAC;gBAC/C,MAAM;YACR,KAAK,cAAc;gBACjB,IAAI,CAAC,kBAAkB,CAAC,KAAqB,CAAC,CAAC;gBAC/C,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,CAAC,eAAe,CAAC,KAAqB,CAAC,CAAC;gBAC5C,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;IAEO,eAAe,CAAC,IAAwB,EAAE,IAAwB;QACxE,IAAI,QAAQ;YAAE,OAAO;QAErB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACvC,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACrC;IACH,CAAC;CACF;AAhY2C;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;wCAAkB;AAiB1C;IAAhB,KAAK,EAAE;uCAAyB;AAChB;IAAhB,KAAK,EAAE;uCAAyB;AAEG;IAAnC,KAAK,CAAC,UAAU,CAAC;sCAA8C","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {\n Attachable,\n AttachableController,\n} from '../../internal/controller/attachable-controller.js';\nimport {EASING} from '../../internal/motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/**\n * Interaction states for the ripple.\n *\n * On Touch:\n * - `INACTIVE -> TOUCH_DELAY -> WAITING_FOR_CLICK -> INACTIVE`\n * - `INACTIVE -> TOUCH_DELAY -> HOLDING -> WAITING_FOR_CLICK -> INACTIVE`\n *\n * On Mouse or Pen:\n * - `INACTIVE -> WAITING_FOR_CLICK -> INACTIVE`\n */\nenum State {\n /**\n * Initial state of the control, no touch in progress.\n *\n * Transitions:\n * - on touch down: transition to `TOUCH_DELAY`.\n * - on mouse down: transition to `WAITING_FOR_CLICK`.\n */\n INACTIVE,\n /**\n * Touch down has been received, waiting to determine if it's a swipe or\n * scroll.\n *\n * Transitions:\n * - on touch up: begin press; transition to `WAITING_FOR_CLICK`.\n * - on cancel: transition to `INACTIVE`.\n * - after `TOUCH_DELAY_MS`: begin press; transition to `HOLDING`.\n */\n TOUCH_DELAY,\n /**\n * A touch has been deemed to be a press\n *\n * Transitions:\n * - on up: transition to `WAITING_FOR_CLICK`.\n */\n HOLDING,\n /**\n * The user touch has finished, transition into rest state.\n *\n * Transitions:\n * - on click end press; transition to `INACTIVE`.\n */\n WAITING_FOR_CLICK,\n}\n\n/**\n * Events that the ripple listens to.\n */\nconst EVENTS = [\n 'click',\n 'contextmenu',\n 'pointercancel',\n 'pointerdown',\n 'pointerenter',\n 'pointerleave',\n 'pointerup',\n];\n\n/**\n * Delay reacting to touch so that we do not show the ripple for a swipe or\n * scroll interaction.\n */\nconst TOUCH_DELAY_MS = 150;\n\n/**\n * Used to detect if HCM is active. Events do not process during HCM when the\n * ripple is not displayed.\n */\nconst FORCED_COLORS = isServer\n ? null\n : window.matchMedia('(forced-colors: active)');\n\n/**\n * A ripple component.\n */\nexport class Ripple extends LitElement implements Attachable {\n /**\n * Disables the ripple.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n get htmlFor() {\n return this.attachableController.htmlFor;\n }\n\n set htmlFor(htmlFor: string | null) {\n this.attachableController.htmlFor = htmlFor;\n }\n\n get control() {\n return this.attachableController.control;\n }\n set control(control: HTMLElement | null) {\n this.attachableController.control = control;\n }\n\n @state() private hovered = false;\n @state() private pressed = false;\n\n @query('.surface') private readonly mdRoot!: HTMLElement | null;\n private rippleSize = '';\n private rippleScale = '';\n private initialSize = 0;\n private growAnimation?: Animation;\n private state = State.INACTIVE;\n private rippleStartEvent?: PointerEvent;\n private checkBoundsAfterContextMenu = false;\n private readonly attachableController = new AttachableController(\n this,\n this.onControlChange.bind(this),\n );\n\n attach(control: HTMLElement) {\n this.attachableController.attach(control);\n }\n\n detach() {\n this.attachableController.detach();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n // Needed for VoiceOver, which will create a \"group\" if the element is a\n // sibling to other content.\n this.setAttribute('aria-hidden', 'true');\n }\n\n protected override render() {\n const classes = {\n 'hovered': this.hovered,\n 'pressed': this.pressed,\n };\n\n return html`<div class=\"surface ${classMap(classes)}\"></div>`;\n }\n\n protected override update(changedProps: PropertyValues<Ripple>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.hovered = false;\n this.pressed = false;\n }\n super.update(changedProps);\n }\n\n /**\n * TODO(b/269799771): make private\n * @private only public for slider\n */\n handlePointerenter(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = true;\n }\n\n /**\n * TODO(b/269799771): make private\n * @private only public for slider\n */\n handlePointerleave(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = false;\n\n // release a held mouse or pen press that moves outside the element\n if (this.state !== State.INACTIVE) {\n this.endPressAnimation();\n }\n }\n\n private handlePointerup(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n if (this.state === State.HOLDING) {\n this.state = State.WAITING_FOR_CLICK;\n return;\n }\n\n if (this.state === State.TOUCH_DELAY) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(this.rippleStartEvent);\n return;\n }\n }\n\n private async handlePointerdown(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.rippleStartEvent = event;\n if (!this.isTouch(event)) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(event);\n return;\n }\n\n // after a longpress contextmenu event, an extra `pointerdown` can be\n // dispatched to the pressed element. Check that the down is within\n // bounds of the element in this case.\n if (this.checkBoundsAfterContextMenu && !this.inBounds(event)) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = false;\n\n // Wait for a hold after touch delay\n this.state = State.TOUCH_DELAY;\n await new Promise((resolve) => {\n setTimeout(resolve, TOUCH_DELAY_MS);\n });\n\n if (this.state !== State.TOUCH_DELAY) {\n return;\n }\n\n this.state = State.HOLDING;\n this.startPressAnimation(event);\n }\n\n private handleClick() {\n // Click is a MouseEvent in Firefox and Safari, so we cannot use\n // `shouldReactToEvent`\n if (this.disabled) {\n return;\n }\n\n if (this.state === State.WAITING_FOR_CLICK) {\n this.endPressAnimation();\n return;\n }\n\n if (this.state === State.INACTIVE) {\n // keyboard synthesized click event\n this.startPressAnimation();\n this.endPressAnimation();\n }\n }\n\n private handlePointercancel(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.endPressAnimation();\n }\n\n private handleContextmenu() {\n if (this.disabled) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = true;\n this.endPressAnimation();\n }\n\n private determineRippleSize() {\n const {height, width} = this.getBoundingClientRect();\n const maxDim = Math.max(height, width);\n const softEdgeSize = Math.max(\n SOFT_EDGE_CONTAINER_RATIO * maxDim,\n SOFT_EDGE_MINIMUM_SIZE,\n );\n\n const initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n const maxRadius = hypotenuse + PADDING;\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${initialSize}px`;\n }\n\n private getNormalizedPointerEventCoords(pointerEvent: PointerEvent): {\n x: number;\n y: number;\n } {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getBoundingClientRect();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n private getTranslationCoordinates(positionEvent?: Event) {\n const {height, width} = this.getBoundingClientRect();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - this.initialSize / 2,\n y: startPoint.y - this.initialSize / 2,\n };\n\n return {startPoint, endPoint};\n }\n\n private startPressAnimation(positionEvent?: Event) {\n if (!this.mdRoot) {\n return;\n }\n\n this.pressed = true;\n this.growAnimation?.cancel();\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n this.growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`,\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: EASING.STANDARD,\n fill: ANIMATION_FILL,\n },\n );\n }\n\n private async endPressAnimation() {\n this.state = State.INACTIVE;\n const animation = this.growAnimation;\n let pressAnimationPlayState = Infinity;\n if (typeof animation?.currentTime === 'number') {\n pressAnimationPlayState = animation.currentTime;\n } else if (animation?.currentTime) {\n pressAnimationPlayState = animation.currentTime.to('ms').value;\n }\n\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n return;\n }\n\n await new Promise((resolve) => {\n setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState);\n });\n\n if (this.growAnimation !== animation) {\n // A new press animation was started. The old animation was canceled and\n // should not finish the pressed state.\n return;\n }\n\n this.pressed = false;\n }\n\n /**\n * Returns `true` if\n * - the ripple element is enabled\n * - the pointer is primary for the input type\n * - the pointer is the pointer that started the interaction, or will start\n * the interaction\n * - the pointer is a touch, or the pointer state has the primary button\n * held, or the pointer is hovering\n */\n private shouldReactToEvent(event: PointerEvent) {\n if (this.disabled || !event.isPrimary) {\n return false;\n }\n\n if (\n this.rippleStartEvent &&\n this.rippleStartEvent.pointerId !== event.pointerId\n ) {\n return false;\n }\n\n if (event.type === 'pointerenter' || event.type === 'pointerleave') {\n return !this.isTouch(event);\n }\n\n const isPrimaryButton = event.buttons === 1;\n return this.isTouch(event) || isPrimaryButton;\n }\n\n /**\n * Check if the event is within the bounds of the element.\n *\n * This is only needed for the \"stuck\" contextmenu longpress on Chrome.\n */\n private inBounds({x, y}: PointerEvent) {\n const {top, left, bottom, right} = this.getBoundingClientRect();\n return x >= left && x <= right && y >= top && y <= bottom;\n }\n\n private isTouch({pointerType}: PointerEvent) {\n return pointerType === 'touch';\n }\n\n /** @private */\n async handleEvent(event: Event) {\n if (FORCED_COLORS?.matches) {\n // Skip event logic since the ripple is `display: none`.\n return;\n }\n\n switch (event.type) {\n case 'click':\n this.handleClick();\n break;\n case 'contextmenu':\n this.handleContextmenu();\n break;\n case 'pointercancel':\n this.handlePointercancel(event as PointerEvent);\n break;\n case 'pointerdown':\n await this.handlePointerdown(event as PointerEvent);\n break;\n case 'pointerenter':\n this.handlePointerenter(event as PointerEvent);\n break;\n case 'pointerleave':\n this.handlePointerleave(event as PointerEvent);\n break;\n case 'pointerup':\n this.handlePointerup(event as PointerEvent);\n break;\n default:\n break;\n }\n }\n\n private onControlChange(prev: HTMLElement | null, next: HTMLElement | null) {\n if (isServer) return;\n\n for (const event of EVENTS) {\n prev?.removeEventListener(event, this);\n next?.addEventListener(event, this);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names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CAAC;CACF;AAjY2C;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;wCAAkB;AAiB1C;IAAhB,KAAK,EAAE;uCAAyB;AAChB;IAAhB,KAAK,EAAE;uCAAyB;AAEG;IAAnC,KAAK,CAAC,UAAU,CAAC;sCAA8C","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {\n Attachable,\n AttachableController,\n} from '../../internal/controller/attachable-controller.js';\nimport {EASING} from '../../internal/motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/**\n * Interaction states for the ripple.\n *\n * On Touch:\n * - `INACTIVE -> TOUCH_DELAY -> WAITING_FOR_CLICK -> INACTIVE`\n * - `INACTIVE -> TOUCH_DELAY -> HOLDING -> WAITING_FOR_CLICK -> INACTIVE`\n *\n * On Mouse or Pen:\n * - `INACTIVE -> WAITING_FOR_CLICK -> INACTIVE`\n */\nenum State {\n /**\n * Initial state of the control, no touch in progress.\n *\n * Transitions:\n * - on touch down: transition to `TOUCH_DELAY`.\n * - on mouse down: transition to `WAITING_FOR_CLICK`.\n */\n INACTIVE,\n /**\n * Touch down has been received, waiting to determine if it's a swipe or\n * scroll.\n *\n * Transitions:\n * - on touch up: begin press; transition to `WAITING_FOR_CLICK`.\n * - on cancel: transition to `INACTIVE`.\n * - after `TOUCH_DELAY_MS`: begin press; transition to `HOLDING`.\n */\n TOUCH_DELAY,\n /**\n * A touch has been deemed to be a press\n *\n * Transitions:\n * - on up: transition to `WAITING_FOR_CLICK`.\n */\n HOLDING,\n /**\n * The user touch has finished, transition into rest state.\n *\n * Transitions:\n * - on click end press; transition to `INACTIVE`.\n */\n WAITING_FOR_CLICK,\n}\n\n/**\n * Events that the ripple listens to.\n */\nconst EVENTS = [\n 'click',\n 'contextmenu',\n 'pointercancel',\n 'pointerdown',\n 'pointerenter',\n 'pointerleave',\n 'pointerup',\n];\n\n/**\n * Delay reacting to touch so that we do not show the ripple for a swipe or\n * scroll interaction.\n */\nconst TOUCH_DELAY_MS = 150;\n\n/**\n * Used to detect if HCM is active. Events do not process during HCM when the\n * ripple is not displayed.\n */\nconst FORCED_COLORS = isServer\n ? null\n : window.matchMedia('(forced-colors: active)');\n\n/**\n * A ripple component.\n */\nexport class Ripple extends LitElement implements Attachable {\n /**\n * Disables the ripple.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n get htmlFor() {\n return this.attachableController.htmlFor;\n }\n\n set htmlFor(htmlFor: string | null) {\n this.attachableController.htmlFor = htmlFor;\n }\n\n get control() {\n return this.attachableController.control;\n }\n set control(control: HTMLElement | null) {\n this.attachableController.control = control;\n }\n\n @state() private hovered = false;\n @state() private pressed = false;\n\n @query('.surface') private readonly mdRoot!: HTMLElement | null;\n private rippleSize = '';\n private rippleScale = '';\n private initialSize = 0;\n private growAnimation?: Animation;\n private state = State.INACTIVE;\n private rippleStartEvent?: PointerEvent;\n private checkBoundsAfterContextMenu = false;\n private readonly attachableController = new AttachableController(\n this,\n this.onControlChange.bind(this),\n );\n\n attach(control: HTMLElement) {\n this.attachableController.attach(control);\n }\n\n detach() {\n this.attachableController.detach();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n // Needed for VoiceOver, which will create a \"group\" if the element is a\n // sibling to other content.\n this.setAttribute('aria-hidden', 'true');\n }\n\n protected override render() {\n const classes = {\n 'hovered': this.hovered,\n 'pressed': this.pressed,\n };\n\n return html`<div class=\"surface ${classMap(classes)}\"></div>`;\n }\n\n protected override update(changedProps: PropertyValues<Ripple>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.hovered = false;\n this.pressed = false;\n }\n super.update(changedProps);\n }\n\n /**\n * TODO(b/269799771): make private\n * @private only public for slider\n */\n handlePointerenter(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = true;\n }\n\n /**\n * TODO(b/269799771): make private\n * @private only public for slider\n */\n handlePointerleave(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = false;\n\n // release a held mouse or pen press that moves outside the element\n if (this.state !== State.INACTIVE) {\n this.endPressAnimation();\n }\n }\n\n private handlePointerup(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n if (this.state === State.HOLDING) {\n this.state = State.WAITING_FOR_CLICK;\n return;\n }\n\n if (this.state === State.TOUCH_DELAY) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(this.rippleStartEvent);\n return;\n }\n }\n\n private async handlePointerdown(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.rippleStartEvent = event;\n if (!this.isTouch(event)) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(event);\n return;\n }\n\n // after a longpress contextmenu event, an extra `pointerdown` can be\n // dispatched to the pressed element. Check that the down is within\n // bounds of the element in this case.\n if (this.checkBoundsAfterContextMenu && !this.inBounds(event)) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = false;\n\n // Wait for a hold after touch delay\n this.state = State.TOUCH_DELAY;\n await new Promise((resolve) => {\n setTimeout(resolve, TOUCH_DELAY_MS);\n });\n\n if (this.state !== State.TOUCH_DELAY) {\n return;\n }\n\n this.state = State.HOLDING;\n this.startPressAnimation(event);\n }\n\n private handleClick() {\n // Click is a MouseEvent in Firefox and Safari, so we cannot use\n // `shouldReactToEvent`\n if (this.disabled) {\n return;\n }\n\n if (this.state === State.WAITING_FOR_CLICK) {\n this.endPressAnimation();\n return;\n }\n\n if (this.state === State.INACTIVE) {\n // keyboard synthesized click event\n this.startPressAnimation();\n this.endPressAnimation();\n }\n }\n\n private handlePointercancel(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.endPressAnimation();\n }\n\n private handleContextmenu() {\n if (this.disabled) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = true;\n this.endPressAnimation();\n }\n\n private determineRippleSize() {\n const {height, width} = this.getBoundingClientRect();\n const maxDim = Math.max(height, width);\n const softEdgeSize = Math.max(\n SOFT_EDGE_CONTAINER_RATIO * maxDim,\n SOFT_EDGE_MINIMUM_SIZE,\n );\n\n const initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n const maxRadius = hypotenuse + PADDING;\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${initialSize}px`;\n }\n\n private getNormalizedPointerEventCoords(pointerEvent: PointerEvent): {\n x: number;\n y: number;\n } {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getBoundingClientRect();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n private getTranslationCoordinates(positionEvent?: Event) {\n const {height, width} = this.getBoundingClientRect();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - this.initialSize / 2,\n y: startPoint.y - this.initialSize / 2,\n };\n\n return {startPoint, endPoint};\n }\n\n private startPressAnimation(positionEvent?: Event) {\n if (!this.mdRoot) {\n return;\n }\n\n this.pressed = true;\n this.growAnimation?.cancel();\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n this.growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`,\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: EASING.STANDARD,\n fill: ANIMATION_FILL,\n },\n );\n }\n\n private async endPressAnimation() {\n this.rippleStartEvent = undefined;\n this.state = State.INACTIVE;\n const animation = this.growAnimation;\n let pressAnimationPlayState = Infinity;\n if (typeof animation?.currentTime === 'number') {\n pressAnimationPlayState = animation.currentTime;\n } else if (animation?.currentTime) {\n pressAnimationPlayState = animation.currentTime.to('ms').value;\n }\n\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n return;\n }\n\n await new Promise((resolve) => {\n setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState);\n });\n\n if (this.growAnimation !== animation) {\n // A new press animation was started. The old animation was canceled and\n // should not finish the pressed state.\n return;\n }\n\n this.pressed = false;\n }\n\n /**\n * Returns `true` if\n * - the ripple element is enabled\n * - the pointer is primary for the input type\n * - the pointer is the pointer that started the interaction, or will start\n * the interaction\n * - the pointer is a touch, or the pointer state has the primary button\n * held, or the pointer is hovering\n */\n private shouldReactToEvent(event: PointerEvent) {\n if (this.disabled || !event.isPrimary) {\n return false;\n }\n\n if (\n this.rippleStartEvent &&\n this.rippleStartEvent.pointerId !== event.pointerId\n ) {\n return false;\n }\n\n if (event.type === 'pointerenter' || event.type === 'pointerleave') {\n return !this.isTouch(event);\n }\n\n const isPrimaryButton = event.buttons === 1;\n return this.isTouch(event) || isPrimaryButton;\n }\n\n /**\n * Check if the event is within the bounds of the element.\n *\n * This is only needed for the \"stuck\" contextmenu longpress on Chrome.\n */\n private inBounds({x, y}: PointerEvent) {\n const {top, left, bottom, right} = this.getBoundingClientRect();\n return x >= left && x <= right && y >= top && y <= bottom;\n }\n\n private isTouch({pointerType}: PointerEvent) {\n return pointerType === 'touch';\n }\n\n /** @private */\n async handleEvent(event: Event) {\n if (FORCED_COLORS?.matches) {\n // Skip event logic since the ripple is `display: none`.\n return;\n }\n\n switch (event.type) {\n case 'click':\n this.handleClick();\n break;\n case 'contextmenu':\n this.handleContextmenu();\n break;\n case 'pointercancel':\n this.handlePointercancel(event as PointerEvent);\n break;\n case 'pointerdown':\n await this.handlePointerdown(event as PointerEvent);\n break;\n case 'pointerenter':\n this.handlePointerenter(event as PointerEvent);\n break;\n case 'pointerleave':\n this.handlePointerleave(event as PointerEvent);\n break;\n case 'pointerup':\n this.handlePointerup(event as PointerEvent);\n break;\n default:\n break;\n }\n }\n\n private onControlChange(prev: HTMLElement | null, next: HTMLElement | null) {\n if (isServer) return;\n\n for (const event of EVENTS) {\n prev?.removeEventListener(event, this);\n next?.addEventListener(event, this);\n }\n }\n}\n"]}