Oops, fix showing the magic magnifier in Firefox
Oh, guess Firefox doesn't support this CSS container query feature yet! Use a more compatible technique instead.
This commit is contained in:
parent
34bf27069b
commit
019484b6dd
2 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
|||
class MagicMagnifier extends HTMLElement {
|
||||
#internals = this.attachInternals();
|
||||
|
||||
connectedCallback() {
|
||||
setTimeout(() => this.#attachLens(), 0);
|
||||
this.addEventListener("mousemove", this.#onMouseMove);
|
||||
|
@ -18,6 +20,7 @@ class MagicMagnifier extends HTMLElement {
|
|||
const y = e.clientY - rect.top;
|
||||
this.style.setProperty("--magic-magnifier-x", x + "px");
|
||||
this.style.setProperty("--magic-magnifier-y", y + "px");
|
||||
this.#internals.states.add("ready");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@ magic-magnifier
|
|||
magic-magnifier-lens
|
||||
display: none
|
||||
|
||||
&:hover
|
||||
@container style(--magic-magnifier-x) and style(--magic-magnifier-y)
|
||||
magic-magnifier-lens
|
||||
display: block
|
||||
// TODO: Once container query support is broader, we can remove the CSS state
|
||||
// and read for the presence of the X and Y custom properties instead.
|
||||
&:hover:state(ready)
|
||||
magic-magnifier-lens
|
||||
display: block
|
||||
|
||||
magic-magnifier-lens
|
||||
width: var(--magic-magnifier-lens-width, 100px)
|
||||
|
|
Loading…
Reference in a new issue