motiondivision / motiondivision/motion

[FEATURE] rangeStart and the rangeEnd support

Open
#3,001 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

Is your feature request related to a problem? Please describe.

Issue: Need for rangeStart/rangeEnd Attributes Despite offset

The CSS attributes animation-range-end and animation-range-start have corresponding rangeStart/rangeEnd attributes in the Web Animations API.

Question:

Why are rangeStart and rangeEnd needed if we already have offset?

The issue arises with entry animations.


Example with Native CSS:

In this example, a :hover animation works after the scroll-linked animation completes:

@keyframes animate-in-range {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.box-right {
  animation: linear animate-in-range;
  animation-timeline: scroll();
  animation-range: 0% 20%;
}

.box-right:hover {
  opacity: 0.5; /* After 20% this works!!!! */
}

/* animated element has anim.effect.getComputedTiming().progress === null after 20% scroll and hover is working */

Native WAAPI example

const timeline = new ScrollTimeline();

const animation = boxNative.animate(
	{
		opacity: [0, 1]
	},
	{
		rangeStart: '0%',
		rangeEnd: '20%',
		timeline
	}
);

/* animated element has anim.effect.getComputedTiming().progress === null after 20% scroll and hover is working */

When using Motion Dev, the behavior is different:

const animation = animate(
  box,
  {
    opacity: [0, 1],
  },
  {
    // rangeStart, rangeEnd not supported
  }
);

const scrollAnimation = scroll(animation, { offset: ['0%', '20%'] });

// animated element has anim.effect.getComputedTiming().progress === 1 even after 20% and hover is not working

With native CSS, the animation’s progress is null after the defined range.
However, when using Motion Dev, the animation’s progress remains 1 even after the range (e.g., 20%).
This creates a discrepancy in expected behavior, especially for animations like :hover out of defined range

Describe the solution you'd like

Support for the corresponding rangeStart/rangeEnd attributes like in the Web Animations API.

Or at least allow pass native options to the https://github.com/motiondivision/motion/blob/c5898f5e5ed652bbdf8a93e76733710260bd6dab/packages/framer-motion/src/animation/animators/waapi/index.ts#L9-L14
to have chrome support

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/framer-motion/src/animation/animators/waapi/index.ts, the entry point named in the issue, and compare its options handling with the supplied native WAAPI and CSS examples. Done means the animation API supports rangeStart/rangeEnd or permits the relevant native options, with progress behavior matching the requested defined-range semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.