Skip to content

Commit

Permalink
blech
Browse files Browse the repository at this point in the history
  • Loading branch information
rotu committed Nov 18, 2022
1 parent 6d66340 commit e1e48e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/useFps/index.ts
Expand Up @@ -19,9 +19,10 @@ export function useFps(options?: UseFpsOptions): Ref<number> {
let last = performance.now()
let ticks = 0

useRafFn((now) => {
useRafFn(() => {
ticks += 1
if (ticks >= every) {
const now = performance.now()
const diff = now - last
fps.value = Math.round(1000 / (diff / ticks))
last = now
Expand Down
5 changes: 3 additions & 2 deletions packages/core/useTransition/index.ts
Expand Up @@ -170,7 +170,8 @@ export function useTransition(
let startVector: number[]

// transition loop
const { resume, pause } = useRafFn((now) => {
const { resume, pause } = useRafFn(() => {
const now = Date.now()
const progress = clamp(1 - ((endAt - now) / currentDuration), 0, 1)

outputVector.value = startVector.map((val, i) => val + ((diffVector[i] ?? 0) * currentTransition.value(progress)))
Expand All @@ -188,7 +189,7 @@ export function useTransition(
currentDuration = unref(duration)
diffVector = outputVector.value.map((n, i) => (sourceVector.value[i] ?? 0) - (outputVector.value[i] ?? 0))
startVector = outputVector.value.slice(0)
startAt = performance.now()
startAt = Date.now()
endAt = startAt + currentDuration

resume()
Expand Down

0 comments on commit e1e48e0

Please sign in to comment.