How to use the popmotion.spring function in popmotion

To help you get started, we’ve selected a few popmotion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github littlebits / react-popover / source / components / PopoverCore.tsx View on Github external
animatePopoverToLayout(layout: Forto.Calculation) {
    Popmotion.spring({
      from: this.popoverReaction.get(),
      to: { ...layout.popover, opacity: 1 },
      velocity: this.popoverReaction.getVelocity(),
      stiffness: 450,
      damping: 35,
      mass: 1.5,
    }).start(this.popoverReaction)
  }
github Popmotion / popmotion / packages / site / templates / Popmotion / LiveExamples / Spring.js View on Github external
listen(document, 'mouseup touchend').start(() => {
      spring({
        from: this.ballXY.get(),
        velocity: this.ballXY.getVelocity(),
        to: { x: 0, y: 0 },
        stiffness: 200
      }).start(this.ballXY);
    });
  };
github framer / motion / src / value / use-spring.ts View on Github external
return value.attach((v, set) => {
            if (activeSpringAnimation.current) {
                activeSpringAnimation.current.stop()
            }

            activeSpringAnimation.current = spring({
                from: value.get(),
                to: v,
                velocity: value.getVelocity(),
                ...config,
            }).start(set)

            return value.get()
        })
    }, Object.values(config))
github Popmotion / popmotion / packages / site / templates / Popmotion / LiveExamples / Physics.js View on Github external
const checkBounce = () => {
      if (!isFalling || ballY.get() < 0) return;

      isFalling = false;
      const impactVelocity = ballY.getVelocity();
      const compression = spring({
        to: 1,
        from: 1,
        velocity: -impactVelocity * 0.01,
        stiffness: 800
      })
        .pipe(s => {
          if (s >= 1) {
            s = 1;
            compression.stop();

            if (impactVelocity > 20) {
              isFalling = true;
              gravity.set(0).setVelocity(-impactVelocity * 0.5);
            }
          }
          return s;