LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Springs & physics

Momentum

Also called inertia, inertial scrolling, or fling

The glide an element keeps after a throw or flick, slowing down gradually like an object sliding across a smooth table.

import { animate, motion, useMotionValue } from 'motion/react';

const SLIDE_WIDTH = 320;
const SNAP = { type: 'spring', stiffness: 300, damping: 35 } as const;
const photos = [
  { src: '/photos/lisbon.jpg', alt: 'A yellow tram on a hill in Lisbon' },
  { src: '/photos/kyoto.jpg', alt: 'A temple path in Kyoto' },
  { src: '/photos/oaxaca.jpg', alt: 'A colorful street in Oaxaca' }
];

export function PhotoCarousel() {
  const x = useMotionValue(0);

  function step(direction: 1 | -1) {
    const index = Math.round(-x.get() / SLIDE_WIDTH) + direction;
    const clamped = Math.min(Math.max(index, 0), photos.length - 1);
    animate(x, -clamped * SLIDE_WIDTH, SNAP);
  }

  return (
    <div
      tabIndex={0}
      role='region'
      aria-roledescription='carousel'
      aria-label='Trip photos'
      onKeyDown={(event) => {
        if (event.key === 'ArrowRight') step(1);
        if (event.key === 'ArrowLeft') step(-1);
      }}
      className='w-80 overflow-hidden rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ring'
    >
      <motion.div
        drag='x'
        style={{ x }}
        dragConstraints={{ left: -(photos.length - 1) * SLIDE_WIDTH, right: 0 }}
        dragElastic={0.2}
        dragTransition={{
          power: 0.3, // how far a flick carries
          timeConstant: 300, // how long the glide lasts, in ms
          // Glide toward the nearest slide instead of stopping between two.
          modifyTarget: (target) =>
            Math.round(target / SLIDE_WIDTH) * SLIDE_WIDTH
        }}
        className='flex cursor-grab touch-pan-y active:cursor-grabbing'
      >
        {photos.map((photo) => (
          <img
            key={photo.src}
            src={photo.src}
            alt={photo.alt}
            draggable={false}
            className='h-56 w-80 shrink-0 object-cover'
          />
        ))}
      </motion.div>
    </div>
  );
}
Make the photo carousel draggable with momentum: after a flick, let it glide and slow down over about 300ms, then snap to the nearest slide. Stop at the first and last slides with a small elastic bounce, and support touch, mouse, and arrow keys.

Paste into Layerwise or any AI coding tool.

What is Momentum?

With momentum, a dragged element keeps moving after you let go. It travels in the direction of the throw at the speed of your hand, then slows smoothly to a stop. A harder flick travels further. Scrolling on phones and trackpads works this way.

Use it for things people throw: carousels, swipeable cards, maps, and canvases. Combine it with snap points so the element lands on a sensible spot, such as the nearest slide, and with an elastic edge so a throw past the end bounces back.

Motion’s drag gesture adds momentum by default (dragMomentum), and dragTransition tunes it: power sets how far a throw carries, and timeConstant sets how long the glide lasts. Turn it off for precise controls, where an item should stay exactly where it was dropped.

Often confused with

Velocity
Velocity is the speed at the moment of release. Momentum is the glide that speed produces afterward.
Smooth scrolling
Smooth scrolling eases the page toward each wheel turn or key press. Momentum is the glide that continues after a flick.

Related terms

All terms

Velocity

The speed and direction an element already has when an animation starts, which a spring carries forward so a flick flows into what follows.

Drag gesture

Moving an element by pressing on it and sliding the pointer or finger, usually within set bounds and with a glide after release.

Rubber-banding

An edge effect where content dragged past its limit moves less than your finger, then springs back on release, like a stretched rubber band.

Scroll snap

A CSS feature that makes a scroll container settle on set points, so carousels and full-screen sections come to rest neatly on an item.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit

With momentum

Without momentum