0

I need to store the pointer X position in a variable. According popmotion documentation (See link here) the following would do the trick:

import { pointer } from 'popmotion';
pointer().start(({ x }) => console.log(x));

in fact, by using the code above the exact value of x is shown in the console, but I am having troubles in using the value in my code.

I have already tried:

const X = pointer().start(({ x }) => x);
const X = pointer().start(({ x }) => { return x; });

but console.log(X) returns {stop: ƒ}

I am not very familiar with arrow functions and I appreciate any help, thanks

contepql
  • 3
  • 4

1 Answers1

0
 let x;
 pointer.start(it => x = it.x);

Note that x will be undefined until start calls back.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151