Skip to content

Commit a75f40c

Browse files
byronogisantfu
andauthored
feat(useTransition): support custom window (#4850)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent d581239 commit a75f40c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/useTransition/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue'
2+
import type { ConfigurableWindow } from '../_configurable'
23
import { identity as linear, promiseTimeout, tryOnScopeDispose } from '@vueuse/shared'
34
import { computed, ref as deepRef, toValue, watch } from 'vue'
5+
import { defaultWindow } from '../_configurable'
46

57
/**
68
* Cubic bezier points
@@ -15,7 +17,7 @@ export type EasingFunction = (n: number) => number
1517
/**
1618
* Transition options
1719
*/
18-
export interface TransitionOptions {
20+
export interface TransitionOptions extends ConfigurableWindow {
1921

2022
/**
2123
* Manually abort a transition
@@ -140,6 +142,9 @@ export function executeTransition<T extends number | number[]>(
140142
to: MaybeRefOrGetter<T>,
141143
options: TransitionOptions = {},
142144
): PromiseLike<void> {
145+
const {
146+
window = defaultWindow,
147+
} = options
143148
const fromVal = toValue(from)
144149
const toVal = toValue(to)
145150
const v1 = toVec(fromVal)
@@ -175,7 +180,7 @@ export function executeTransition<T extends number | number[]>(
175180
(source.value as number) = arr[0]
176181

177182
if (now < endAt) {
178-
requestAnimationFrame(tick)
183+
window?.requestAnimationFrame(tick)
179184
}
180185
else {
181186
source.value = toVal

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy