Get started with gsap CDN

Standard 'No Charge' GreenSock License licensed

Powerful, lightweight library: GSAP animates web interactions.

Tags:
  • GSAP
  • GreenSock
  • animation
  • motion
  • MotionPathPlugin
  • motionPath
  • TweenMax
  • SVG
  • JavaScript
  • animate
  • easing
  • EasePack
  • Bezier
  • 3D
  • 2D
  • transform
  • tweening

Stable version

Copied!

How to start using gsap CDN


<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="styles.css">
  <script src="https://cdn.cdnhub.io/gsap/3.12.5/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap/dist/utils/Draggable.min.js"></script>
  <script src="main.js"></script>
</head>
<body>
  <div id="box" class="draggable">
    <p>Drag me!</p>
  </div>

  <script>
    gsap.registerPlugin(Draggable);

    const box = document.querySelector('#box');
    new Draggable(box, {
      type: 'x',
      bounds: { minRotation: -180, maxRotation: 180 },
      onDrag: () => {
        gsap.to(box, 0.5, { x: box.x, rotation: box.rotation });
      },
      onRelease: () => {
        gsap.to(box, 1, { x: 0, rotation: 0 });
      },
    });
  </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions