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

Tweening

Also called inbetweening or tween animation

Generating the in-between frames of an animation from a start and an end state, so an element moves smoothly from one to the other.

import { useRef, useState } from 'react';
import { motion, useReducedMotion } from 'motion/react';

const IMAGE = '/products/stoneware-mug.jpg';
type Flight = Record<'id' | 'left' | 'top' | 'width' | 'dx' | 'dy', number>;

export function ProductCard() {
  const imageRef = useRef<HTMLImageElement>(null);
  const cartRef = useRef<HTMLSpanElement>(null);
  const [count, setCount] = useState(0);
  const [flight, setFlight] = useState<Flight | null>(null);
  const reduceMotion = useReducedMotion();

  function addToCart() {
    setCount((n) => n + 1);
    const from = imageRef.current?.getBoundingClientRect();
    const to = cartRef.current?.getBoundingClientRect();
    if (reduceMotion || !from || !to) return;
    const { left, top, width } = from;
    // Fly from the image's center to the cart's center.
    const dx = to.x + to.width / 2 - (left + width / 2);
    const dy = to.y + to.height / 2 - (top + from.height / 2);
    setFlight({ id: Date.now(), left, top, width, dx, dy });
  }

  return (
    <div className='flex w-72 flex-col gap-4'>
      <span ref={cartRef} className='self-end text-sm font-medium'>
        Cart ({count})
      </span>
      <img
        ref={imageRef}
        src={IMAGE}
        alt='Stoneware mug'
        className='aspect-square rounded-xl object-cover'
      />
      <button
        type='button'
        onClick={addToCart}
        className='rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground'
      >
        Add to cart
      </button>
      {flight && (
        <motion.img
          key={flight.id}
          src={IMAGE}
          alt=''
          // A tween: start, end, a fixed 500ms, and one easing curve.
          initial={{ x: 0, y: 0, scale: 1 }}
          animate={{ x: flight.dx, y: flight.dy, scale: 0.3 }}
          transition={{ type: 'tween', duration: 0.5, ease: 'easeInOut' }}
          onAnimationComplete={() => setFlight(null)}
          style={{ left: flight.left, top: flight.top, width: flight.width }}
          className='pointer-events-none fixed aspect-square rounded-xl object-cover'
        />
      )}
    </div>
  );
}
When a product is added to the cart, tween a copy of its thumbnail from the product card to the cart icon over 500ms with an ease-in-out curve, shrinking it from scale 1 to 0.3 on the way. Animate only transform and opacity, and skip the flight when prefers-reduced-motion is set.

Paste into Layerwise or any AI coding tool.

What is Tweening?

Tweening, short for in-betweening, comes from hand-drawn animation: a lead artist drew the key poses and assistants drew the frames between them. On the web the browser or an animation library does that work, calculating a new frame for every screen refresh.

You describe the start state, the end state, a duration, and an easing curve. The easing decides how the in-between frames are spaced: evenly with linear, bunched up at both ends with ease-in-out. CSS transitions, CSS animations, and libraries such as Motion and GSAP all tween.

A tween always takes the same, exact amount of time, which makes it predictable and easy to line up with other motion. A spring animation is the main alternative: it has no fixed duration, and it handles being interrupted halfway through more naturally.

Often confused with

Spring animation
A spring animation is driven by physics settings and has no fixed duration. A tween runs for an exact time along an easing curve.

Related terms

All terms

Keyframes

Snapshots that define how an element looks at set points in an animation. The browser fills in the motion between them.

Easing

A curve that controls how an animation’s speed changes over time, so motion can start slow, land softly, or keep one steady pace.

Spring animation

An animation driven by simulated spring physics in place of a fixed duration and curve, so motion can overshoot, settle, and react naturally.

Frame rate (FPS)

The number of frames a screen draws each second; around 60 fps, motion looks smooth, and at lower rates it starts to look choppy.

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
Start
End