1 | import { TweenMax } from 'gsap';
|
2 | import * as log from 'loglevel';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | function warp(elementToMove: Element, targetElement: Element): void {
|
8 | const box = targetElement.getBoundingClientRect();
|
9 | const targetLeft = box.left;
|
10 |
|
11 | log.debug("targetLeft is %o", targetLeft);
|
12 |
|
13 |
|
14 | const sourceLeft = elementToMove.getBoundingClientRect().left;
|
15 | log.debug("sourceLeft is %o", sourceLeft);
|
16 |
|
17 | const diff = sourceLeft - targetLeft;
|
18 |
|
19 | log.debug("will move %o", diff);
|
20 |
|
21 | TweenMax.to(elementToMove, 1, { x: -diff });
|
22 | }
|
23 |
|
24 | export default { warp };
|