Skip to content

Commit a9f3553

Browse files
authored
Merge pull request #3250 from piotrjoniec/main
Add support for defining a timeline position relative to the start of the most recently added animation (e.g. `<0.5`, `<-1`)
2 parents 894f631 + 8a108ff commit a9f3553

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Motion adheres to [Semantic Versioning](http://semver.org/).
44

55
Undocumented APIs should be considered internal and may change without warning.
66

7+
## [12.17.0] 2025-06-08
8+
9+
### Added
10+
11+
- Support for defining a timeline position relative to the start of the most recently added animation (e.g. `<0.5`, `<-1`)
12+
713
## [12.17.3] 2025-06-12
814

915
### Changed

packages/framer-motion/src/animation/sequence/utils/__tests__/calc-time.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ describe("calcNextTime", () => {
2020

2121
// Previous
2222
expect(calcNextTime(5, "<", 100, labels)).toBe(100)
23+
24+
// Relative to previous
25+
expect(calcNextTime(5, "<1", 100, labels)).toBe(101)
26+
expect(calcNextTime(5, "<-1", 100, labels)).toBe(99)
27+
expect(calcNextTime(5, "<2.5", 100, labels)).toBe(102.5)
28+
expect(calcNextTime(5, "<-2.5", 100, labels)).toBe(97.5)
29+
expect(calcNextTime(5, "<-150", 100, labels)).toBe(0)
2330
})
2431
})

packages/framer-motion/src/animation/sequence/utils/calc-time.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export function calcNextTime(
1616
return Math.max(0, current + parseFloat(next))
1717
} else if (next === "<") {
1818
return prev
19+
} else if (next.startsWith("<")) {
20+
return Math.max(0, prev + parseFloat(next.slice(1)))
1921
} else {
2022
return labels.get(next) ?? current
2123
}

0 commit comments

Comments
 (0)