Skip to content

Commit

Permalink
Adding delay in seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Oct 2, 2024
1 parent 51ac271 commit f41b701
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Framer Motion adheres to [Semantic Versioning](http://semver.org/).

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

## [11.10.0] 2024-10-02

### Added

- `delay` with seconds now exported from `"framer-motion/dom"`.

### Fixed

- Values no longer added to `will-change` if animation has been skipped.

## [11.9.0] 2024-09-27

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-motion/src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export { keyframes } from "./animation/generators/keyframes"
export { stagger } from "./animation/utils/stagger"
export { transform } from "./utils/transform"
export { clamp } from "./utils/clamp"
export * from "./utils/delay"
export { delayInSeconds as delay, DelayedFunction } from "./utils/delay"
export * from "./utils/distance"
export * from "./utils/errors"
export * from "./utils/interpolate"
Expand Down
3 changes: 3 additions & 0 deletions packages/framer-motion/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,6 @@ export { DeprecatedLayoutGroupContext } from "./context/DeprecatedLayoutGroupCon
export { useAnimatedState as useDeprecatedAnimatedState } from "./animation/hooks/use-animated-state"
export { useInvertedScale as useDeprecatedInvertedScale } from "./value/use-inverted-scale"
export { AnimateSharedLayout } from "./components/AnimateSharedLayout"

// Keep explict delay in milliseconds export for BC with Framer
export { delay, DelayedFunction } from "./utils/delay"
5 changes: 5 additions & 0 deletions packages/framer-motion/src/utils/delay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { frame, cancelFrame } from "../frameloop"
import { time } from "../frameloop/sync-time"
import { FrameData } from "../frameloop/types"
import { secondsToMilliseconds } from "./time-conversion"

export type DelayedFunction = (overshoot: number) => void

Expand All @@ -23,3 +24,7 @@ export function delay(callback: DelayedFunction, timeout: number) {

return () => cancelFrame(checkElapsed)
}

export function delayInSeconds(callback: DelayedFunction, timeout: number) {
return delay(callback, secondsToMilliseconds(timeout))
}

0 comments on commit f41b701

Please sign in to comment.