micha-lmxt / svelte-motion

An animation library for Svelte based on framer-motion.
https://svelte-motion.gradientdescent.de
MIT License
556 stars 13 forks source link

Type checking disable for whileDrag #24

Open dtsmarin opened 2 years ago

dtsmarin commented 2 years ago

I'm getting a type error because I'm trying to use a function inside whileDrag

 whileDrag={handleTouch}
Type '() => void' is not assignable to type 'VariantLabels | TargetAndTransition'.

The code works fine and does exactly what I need though. Execute a function while the object is being dragged.

Is there any way to disable this type checking?

I'm using Svelte with Vite.

micha-lmxt commented 2 years ago

I'm happy when it works for you, but usually 'whileDrag' is not supposed to accept callback. I am somewhat surprised, that it kind of works. I tested myself, it seems the 'whileDrag' is called once the drag starts and once when it is done, both times without any argument.

'onDrag' accepts a callback and is called over and over while dragged.

If you just want to silence Typescript you could cast your handler to 'any' const handleTouch : any = ()=>{...}