🧠 Description
This project recreates a high-quality jelly squish interaction using HTML Canvas and GSAP Draggable.
The illusion of soft, elastic deformation is achieved through frame-by-frame image animation, controlled by vertical drag input and enhanced with inertia, smoothing, and dampening physics.
Why This Interaction Feels Real
- Ultra-smooth drag-based squish effect
- 215 high-resolution image frames
- Inertia-powered elastic motion
- Realistic dampening & easing
- Optional mouse-follow mode
- Mobile-friendly touch support
- Premium UI polish & loader animation
Core Concept
Instead of deforming vectors or meshes, this technique uses:
- Pre-rendered image sequences
- GSAP Draggable Y-axis control
- Frame interpolation with smoothing
- Physics-based dampening
The result feels soft, organic, and physically believable — perfect for buttons, product previews, or playful UI elements.
💻 Step 1: HTML Structure
Complete HTML Code
HTML Breakdown
<canvas> → Renders the jelly animation frames
.drag-trigger → Invisible drag hit-area
.bottom-controls → UI instructions & toggle
.loader → Preload progress feedback
GSAP plugins loaded via CDN
🎨 Step 2: CSS – Layout & Visual Polish
CSS Code
CSS Breakdown
Aspect-ratio: 4/3 → Matches animation frames
Rounded corners → Soft, tactile feel
Fade-in animation → Premium loading experience
Hidden overflow → Prevents layout jitter
Pointer control zones → UX-focused interaction
⚙️ Step 3: JavaScript – Canvas, Drag & Physics
Image Sequence Setup
let totalFrames = 215; let startFrame = 70; let images = new Array();
Uses 215 pre-rendered images
Starts from a neutral squish state
Images are loaded dynamically
Preloading System
GSAP Draggable Control
Physics & Dampening Logic
const dampening = 1.0 - Math.exp(-smoothing * 60 * dt);
displayFrame += (dragFrame - displayFrame) * dampening;
Why This Works:
Simulates soft elastic resistance
Prevents jitter
Creates natural jelly motion
Adapts smoothly to fast or slow input
Canvas Rendering Loop
Only redraws when frame changes
Optimized for performance
Image smoothing enabled for realism
🖱️ Interaction Modes
Drag Mode
Vertical drag controls squish
Inertia continues motion
Resistance feels physical
Follow Mouse Mode
Frame follows cursor Y-position
Draggable disabled automatically
Great for demos & hero interactions
