JavaScript Flip & Tilt Animations - justFlipIt v4
| File Size: | 123 KB |
|---|---|
| Views Total: | 8751 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
justFlipIt is a dependency-free JavaScript library for 3D card flips, fade and scale transitions, and interactive tilt effects on HTML elements.
It supports mouse, touch, and keyboard interactions, with responsive front and back faces and adapters for React, Vue, and Svelte.
Note that Version 4 uses a JavaScript controller API and no longer registers a jQuery plugin.
Features
- 3D flip animations around the horizontal or vertical axis.
- Fade and scale effects with configurable duration and easing.
- Hover, click, and delegated click triggers.
- Pointer-driven tilt for mouse and touch input.
- Responsive CSS Grid layout with generated or existing front and back faces.
- Keyboard controls, hidden-face accessibility attributes, and reduced-motion handling.
- Controller methods for flipping, updating options, reading state, and cleanup.
- React hook, Vue directive, and Svelte action.
How to Use justFlipIt v4
1. Browser script and basic flip card
Load the v4 browser bundle after the card markup.
<div class="product-card"> <h3>Product details</h3> <p>Click to see the other side.</p> </div> <script src="https://cdn.jsdelivr.net/npm/@simhub2/[email protected]/dist/justFlipIt.min.js"></script> <script> const card = justFlipIt(document.querySelector('.product-card'), { Click: true, Template: '<h3>Specifications</h3><p>Available in three colors.</p>', Duration: 450 }); </script>
2. Install with npm and import as an ES module
npm install @simhub2/justflipit
import justFlipIt from '@simhub2/justflipit';
const card = justFlipIt(document.querySelector('.product-card'), {
Click: true,
Effect: 'flip',
FlipX: true
});
3. Animate existing front and back faces
Use Faces when both sides already exist as direct children of the card.
<div class="feature-card">
<div data-flip-front>
<h3>Front</h3>
<p>Product summary</p>
</div>
<div data-flip-back>
<h3>Back</h3>
<p>Additional details</p>
</div>
</div>
const featureCard = justFlipIt(document.querySelector('.feature-card'), {
Faces: {
front: '[data-flip-front]',
back: '[data-flip-back]'
},
Click: true,
Effect: 'fade',
Tilt: { max: 10, perspective: 1000, scale: 1.03 }
});
4. Configure flip direction, tilt, and panel styles
<div class="animated-card">Hover or click to flip.</div>
const animatedCard = justFlipIt(document.querySelector('.animated-card'), {
Click: true,
FlipX: true,
Effect: 'flip',
Duration: 500,
Easing: 'ease-in-out',
Tilt: { max: 12, perspective: 800, scale: 1.02 },
Style: [
{ el: '[data-jfi-face="front"]', style: { backgroundColor: '#243b2b' } },
{ el: '[data-jfi-face="back"]', style: { backgroundColor: '#c1f384' } }
]
});
Available Options
| Option | Default and behavior |
|---|---|
Click |
false. Hover to flip by default; true for click, or a selector/array of selectors for delegated click triggers. |
FlipX |
false. Rotate around the X-axis when true; Y-axis otherwise. |
Template |
Clone of the original element when omitted. Accepts trusted HTML for the generated back face. |
Duration |
400. Animation duration in milliseconds. |
Easing |
cubic-bezier(.22,.61,.36,1). CSS transition easing. |
Effect |
'flip'. Also accepts 'fade' and 'scale'. |
Tilt |
false. Accepts true, 'only', or an object with max, perspective, and scale. |
ReducedMotion |
true. Respond to changes in prefers-reduced-motion. |
Faces |
Omitted. Specify existing direct-child faces with { front: selector, back: selector }. |
preserveClasses |
true. Copy the original element's classes onto a generated panel. |
preserveStyles |
true. Copy its inline styles onto a generated panel. |
Style |
[]. Apply style entries with el and style fields to the panel or selected descendants. |
Controller Methods and Events
Passing one DOM element returns a controller. Passing a CSS selector or an element collection returns an array of controllers.
const cardElement = document.querySelector('.product-card');
const controller = justFlipIt.get(cardElement);
controller.flip(); // Show the back
controller.flip(false); // Show the front
controller.toggle(); // Switch sides
controller.update({ Effect: 'scale' }); // Change the effect
const state = controller.getState(); // { flipped, destroyed, effect }
// Static helpers for existing instances:
justFlipIt.get(cardElement);
justFlipIt.destroy(cardElement); // Destroy the matching instance
// Or destroy through its controller:
controller.destroy();
Initialize a group of cards with a selector and manage each controller individually.
const cards = justFlipIt('.product-card', { Click: true });
cards.forEach(card => card.flip());
The justflipit:change custom event fires on the controller panel when the visible face changes.
card.hoverPanel.addEventListener('justflipit:change', event => {
console.log(event.detail.flipped, event.detail.effect);
});
React, Vue, and Svelte Integrations
| Framework | v4 integration |
|---|---|
| React 18+ | useFlip from @simhub2/justflipit/react |
| Vue 3 | vFlip directive from @simhub2/justflipit/vue |
| Svelte 4/5 | flip action from @simhub2/justflipit/svelte |
Agent Tool Integration
The optional agent bridge exposes a JSON-schema tool definition and an executor for registered cards. Actions include state, flip, reset, toggle, and setText.
import justFlipIt from '@simhub2/justflipit';
import { createAgentBridge } from '@simhub2/justflipit/agent';
const product = justFlipIt(document.querySelector('.product-card'), {
Click: true
});
const bridge = createAgentBridge({ product });
bridge.execute({ id: 'product', action: 'setText', text: 'More product details.' });
bridge.execute({ id: 'product', action: 'flip' });
Upgrading from v3 and jQuery
Version 4 removes $.fn.justFlipIt registration. Call the JavaScript function directly, and use controller methods for programmatic interaction and cleanup. Option names are case-sensitive, including Click, Template, FlipX, Duration, Easing, and Style.
Older justFlipIt-modern, justFlipIt-vanilla, and justFlipIt-combined browser filenames are aliases of the v4 core. Existing .front/.backY selectors and ._flip_ state classes have changed to [data-jfi-face="front"], [data-jfi-face="back"], and [data-jfi-flipped="true"].
// v3 jQuery integration (legacy):
$('.flip-card').justFlipIt({ Click: true });
// v4 Vanilla JavaScript integration:
const cards = justFlipIt('.flip-card', { Click: true });
cards.forEach(card => card.toggle());
Changelog:
v4.0.1 (2026-11-07)
- Added touch-driven 3D tilt and reset on finger release or scrolling.
- Improved tap-to-flip behavior for flip, fade, and scale effects.
- Restricted axis rotation to the flip effect.
- Updated demos.
v4.0.0
- Removed jQuery plugin registration and unified the browser, ESM, and CommonJS implementations.
- Added responsive face layouts, fade and scale transitions, and controller methods.
- Added React, Vue, Svelte, and agent tool integrations.
- Added keyboard, touch, and reduced-motion behavior.
v3.2.2 (2025-07-16)
- modified tilt-effect for mobile
v3.2.1 (2025-07-15)
- added Tilt-Effect
v3.1.1 (2025-05-28)
- small Bugfixes
v3.1.0 (2025-05-26)
- Added new options
v3.0.1 (2025-05-24)
- Works with or without jQuery
- Multiple import methods (script tag, npm, ES modules)
- Lightweight and fast
- Compatible with all modern browsers and legacy browsers (with fallbacks)
- Uses modern Web Animations API when available
- Easy to customize with CSS
- Bugfix
- Doc updated
- Demo updated
v2.0 (2019-07-30)
- new feature - destroy()
- some bug fixes
2018-01-11
- update
Related jQuery Flip Plugins
- Touch-enabled 3D Flipping Animations - Flip Box
- jQuery Plugin To Rotate An Element with 3D Flip Effects - Flipper
This awesome jQuery plugin is developed by SimHub. For more Advanced Usages, please check the demo page or visit the official website.











