Skip to content

Commit

Permalink
img-zoom | Use a better-feeling zoom animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Auroratide committed Nov 9, 2024
1 parent 129a6bf commit ead21a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-humans-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@auroratide/img-zoom": patch
---

Use a better-feeling default animation for zooming
6 changes: 4 additions & 2 deletions components/img-zoom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { pop, fade, type AnimationDescription } from "./animation.js"
export class ImgZoomElement extends HTMLElement {
static defaultElementName = "img-zoom"

static defaultAnimation = "cubic-bezier(0.25, 1, 0.5, 1)"

static html = `
<button id="zoom-in">
<slot></slot>
Expand Down Expand Up @@ -227,7 +229,7 @@ export class ImgZoomElement extends HTMLElement {

const animate = (animation: AnimationDescription) =>
this.#content().animate(animation.keyframes, {
easing: "ease-out",
easing: ImgZoomElement.defaultAnimation,
...animation.options,
fill: "none",
composite: "add",
Expand All @@ -247,7 +249,7 @@ export class ImgZoomElement extends HTMLElement {
const animate = (animation: AnimationDescription) =>
this.#content().animate(animation.keyframes, {
...animation.options,
easing: invertEasing(animation.options?.easing ?? "ease-out"),
easing: invertEasing(animation.options?.easing ?? ImgZoomElement.defaultAnimation),
fill: "none",
direction: "reverse",
composite: "add",
Expand Down

0 comments on commit ead21a5

Please sign in to comment.