|
|
import { SpringValue } from './SpringValue' |
|
|
import { to } from './interpolate' |
|
|
import { addFluidObserver } from '@react-spring/shared' |
|
|
|
|
|
describe('Interpolation', () => { |
|
|
it.todo('can use a SpringValue') |
|
|
it.todo('can use another Interpolation') |
|
|
it.todo('can use a non-animated FluidValue') |
|
|
|
|
|
describe('when multiple inputs change in the same frame', () => { |
|
|
it.todo('only computes its value once') |
|
|
}) |
|
|
|
|
|
describe('when an input resets its animation', () => { |
|
|
it.todo('computes its value before the first frame') |
|
|
}) |
|
|
|
|
|
describe('when all inputs are paused', () => { |
|
|
it('leaves the frameloop', () => { |
|
|
const a = new SpringValue({ from: 0, to: 1 }) |
|
|
const b = new SpringValue({ from: 1, to: 0 }) |
|
|
global.mockRaf.step() |
|
|
|
|
|
const calc = jest.fn((a: number, b: number) => Math.abs(a - b)) |
|
|
const c = to([a, b], calc) |
|
|
|
|
|
|
|
|
const observer = jest.fn() |
|
|
addFluidObserver(c, observer) |
|
|
|
|
|
|
|
|
a.pause() |
|
|
|
|
|
|
|
|
calc.mockClear() |
|
|
global.mockRaf.step() |
|
|
expect(calc).toBeCalled() |
|
|
|
|
|
|
|
|
b.pause() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calc.mockClear() |
|
|
global.mockRaf.step() |
|
|
expect(calc).toBeCalled() |
|
|
expect(c.idle).toBeTruthy() |
|
|
|
|
|
|
|
|
calc.mockClear() |
|
|
global.mockRaf.step() |
|
|
expect(calc).not.toBeCalled() |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|