@simhub2/justflipit 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -0
- package/dist/justFlipIt-modern.js +483 -0
- package/dist/justFlipIt-modern.min.js +1 -0
- package/dist/justFlipIt-vanilla.js +329 -0
- package/dist/justFlipIt-vanilla.min.js +1 -0
- package/dist/justFlipIt.js +377 -0
- package/dist/justFlipIt.min.js +1 -0
- package/dist/types/justFlipIt.d.ts +43 -0
- package/package.json +91 -0
- package/src/justFlipIt-combined.js +377 -0
- package/src/justFlipIt-combined.min.js +1 -0
- package/src/justFlipIt-modern.js +483 -0
- package/src/justFlipIt-modern.min.js +1 -0
- package/src/justFlipIt-vanilla.js +329 -0
- package/src/justFlipIt-vanilla.min.js +1 -0
- package/src/justFlipIt.d.ts +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# justFlipIt
|
|
2
|
+
|
|
3
|
+
A lightweight JavaScript library that allows you to implement CSS3 based flip animations on any DOM elements.
|
|
4
|
+
|
|
5
|
+
## 🚀 [**Live Demo**](https://SimHub.github.io/justFlipIt/)
|
|
6
|
+
|
|
7
|
+
> **Try it out!** Click the link above to see justFlipIt in action with interactive examples.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/justflipit)
|
|
10
|
+
[](https://www.npmjs.com/package/justflipit)
|
|
11
|
+
[](https://github.com/SimHub/justFlipIt)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ⚡ **Lightweight & Fast** - Minimal footprint with maximum performance
|
|
16
|
+
- 🎨 **Highly Customizable** - Easy to style with CSS and customize animations
|
|
17
|
+
- 📱 **Modern Browser Support** - Works with all modern browsers and graceful fallbacks
|
|
18
|
+
- 🔧 **Multiple Import Methods** - Script tag, npm, ES modules - use however you prefer
|
|
19
|
+
- 🎯 **Works with or without jQuery** - Choose your preferred approach
|
|
20
|
+
- 🎭 **3D Flip Animations** - Beautiful CSS3 transform-based animations
|
|
21
|
+
- ⚙️ **Easy Configuration** - Simple options for duration, easing, triggers, and more
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### CDN (Easiest)
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/justflipit@latest/dist/justFlipIt.min.js"></script>
|
|
29
|
+
<script>
|
|
30
|
+
justFlipIt(".my-card");
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
NPM
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install justflipit
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import justFlipIt from "justflipit";
|
|
42
|
+
justFlipIt(".my-card");
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Basic Usage
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<div class="card">
|
|
49
|
+
<h3>Front Side</h3>
|
|
50
|
+
<p>Hover over me!</p>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<script>
|
|
54
|
+
// Simple hover flip
|
|
55
|
+
justFlipIt(".card");
|
|
56
|
+
|
|
57
|
+
// Click to flip with custom settings
|
|
58
|
+
justFlipIt(".card", {
|
|
59
|
+
Click: true,
|
|
60
|
+
Duration: 800,
|
|
61
|
+
Easing: "cubic-bezier(0.68, -0.55, 0.27, 1.55)",
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
| Option | Type | Description | Default |
|
|
69
|
+
| -------- | ----------------- | --------------------------------------------------------------------------------- | ------------- |
|
|
70
|
+
| Template | String | HTML content for the back side. If empty, the original element will be cloned. | - |
|
|
71
|
+
| Click | Boolean or String | `true` for click on panel, or CSS selector for click on specific elements. | false (hover) |
|
|
72
|
+
| FlipX | Boolean | `true` for flip around X-axis (vertical), `false` for Y-axis (horizontal). | false |
|
|
73
|
+
| Style | Array | Array of style objects to apply to panel or specific elements within it. | [] |
|
|
74
|
+
| Duration | Number | Duration of flip animation in milliseconds. | 400 |
|
|
75
|
+
| Easing | String | CSS easing function for animation, e.g. "linear", "ease-in", "cubic-bezier(...)". | "ease-in-out" |
|
|
76
|
+
|
|
77
|
+
### Style Object Format
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
{
|
|
81
|
+
el: "self", // "self" or CSS selector (e.g. ".front", ".back")
|
|
82
|
+
style: {
|
|
83
|
+
borderRadius: "10px",
|
|
84
|
+
boxShadow: "0 4px 8px rgba(0,0,0,0.2)"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
### Hover Effects
|
|
92
|
+
|
|
93
|
+
```html
|
|
94
|
+
<div class="hover-card">Hover me!</div>
|
|
95
|
+
<script>
|
|
96
|
+
justFlipIt(".hover-card", {
|
|
97
|
+
Duration: 500,
|
|
98
|
+
Easing: "ease-out",
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Click Interactions
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<div class="click-card">Click me!</div>
|
|
107
|
+
<script>
|
|
108
|
+
justFlipIt(".click-card", {
|
|
109
|
+
Click: true,
|
|
110
|
+
Duration: 600,
|
|
111
|
+
Easing: "ease-in-out",
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Custom Back Content
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<div class="custom-card">Front Content</div>
|
|
120
|
+
<script>
|
|
121
|
+
justFlipIt(".custom-card", {
|
|
122
|
+
Click: true,
|
|
123
|
+
Template:
|
|
124
|
+
'<div style="padding: 20px;"><h3>Back Side</h3><p>Custom content!</p></div>',
|
|
125
|
+
});
|
|
126
|
+
</script>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Button Trigger
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<div class="button-card">
|
|
133
|
+
Card Content
|
|
134
|
+
<button class="flip-btn">Flip</button>
|
|
135
|
+
</div>
|
|
136
|
+
<script>
|
|
137
|
+
justFlipIt(".button-card", {
|
|
138
|
+
Click: ".flip-btn",
|
|
139
|
+
Duration: 500,
|
|
140
|
+
});
|
|
141
|
+
</script>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Bounce Effect
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<div class="bounce-card">Bounce Effect</div>
|
|
148
|
+
<script>
|
|
149
|
+
justFlipIt(".bounce-card", {
|
|
150
|
+
Click: true,
|
|
151
|
+
Duration: 800,
|
|
152
|
+
Easing: "cubic-bezier(0.68, -0.55, 0.27, 1.55)",
|
|
153
|
+
});
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Custom Styling
|
|
158
|
+
|
|
159
|
+
```html
|
|
160
|
+
<div class="styled-card">Styled Card</div>
|
|
161
|
+
<script>
|
|
162
|
+
justFlipIt(".styled-card", {
|
|
163
|
+
Style: [
|
|
164
|
+
{
|
|
165
|
+
el: "self",
|
|
166
|
+
style: {
|
|
167
|
+
borderRadius: "15px",
|
|
168
|
+
boxShadow: "0 10px 30px rgba(0,0,0,0.2)",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
el: ".front",
|
|
173
|
+
style: {
|
|
174
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
el: ".backY",
|
|
179
|
+
style: {
|
|
180
|
+
background: "linear-gradient(135deg, #f093fb 0%, #f5576c 100%)",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
</script>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Library Versions
|
|
189
|
+
|
|
190
|
+
justFlipIt offers three different versions to suit your needs:
|
|
191
|
+
|
|
192
|
+
### Vanilla Version
|
|
193
|
+
|
|
194
|
+
- **File**: `justFlipIt-vanilla.js` / `.min.js`
|
|
195
|
+
- **Dependencies**: None
|
|
196
|
+
- **Animation**: CSS Transitions
|
|
197
|
+
- **Use case**: Lightweight, no dependencies
|
|
198
|
+
|
|
199
|
+
### Modern Version
|
|
200
|
+
|
|
201
|
+
- **File**: `justFlipIt-modern.js` / `.min.js`
|
|
202
|
+
- **Dependencies**: None
|
|
203
|
+
- **Animation**: Web Animations API with CSS fallback
|
|
204
|
+
- **Use case**: Modern browsers, best performance
|
|
205
|
+
|
|
206
|
+
### Combined Version
|
|
207
|
+
|
|
208
|
+
- **File**: `justFlipIt-combined.js` / `.min.js`
|
|
209
|
+
- **Dependencies**: Optional jQuery support
|
|
210
|
+
- **Animation**: CSS Transitions
|
|
211
|
+
- **Use case**: jQuery and Vanilla JS compatibility
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<!-- Vanilla -->
|
|
215
|
+
<script src="justFlipIt-vanilla.min.js"></script>
|
|
216
|
+
|
|
217
|
+
<!-- Modern -->
|
|
218
|
+
<script src="justFlipIt-modern.min.js"></script>
|
|
219
|
+
|
|
220
|
+
<!-- Combined (with jQuery support) -->
|
|
221
|
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
222
|
+
<script src="justFlipIt-combined.min.js"></script>
|
|
223
|
+
<script>
|
|
224
|
+
// Both work:
|
|
225
|
+
$(".card").justFlipIt();
|
|
226
|
+
justFlipIt(".card");
|
|
227
|
+
</script>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Advanced Example
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<div class="product-card">
|
|
234
|
+
<img src="product.jpg" alt="Product" />
|
|
235
|
+
<h3>Product Name</h3>
|
|
236
|
+
<p>Short description</p>
|
|
237
|
+
<button class="details-btn">Show Details</button>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<script>
|
|
241
|
+
justFlipIt(".product-card", {
|
|
242
|
+
Template: `
|
|
243
|
+
<div class="product-details">
|
|
244
|
+
<h3>Product Details</h3>
|
|
245
|
+
<ul>
|
|
246
|
+
<li>Feature 1: Value</li>
|
|
247
|
+
<li>Feature 2: Value</li>
|
|
248
|
+
<li>Feature 3: Value</li>
|
|
249
|
+
</ul>
|
|
250
|
+
<p class="price">$39.99</p>
|
|
251
|
+
<button class="buy-btn">Buy Now</button>
|
|
252
|
+
<button class="back-btn">Back</button>
|
|
253
|
+
</div>
|
|
254
|
+
`,
|
|
255
|
+
Click: ".details-btn",
|
|
256
|
+
Duration: 800,
|
|
257
|
+
Easing: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
|
|
258
|
+
Style: [
|
|
259
|
+
{
|
|
260
|
+
el: "self",
|
|
261
|
+
style: {
|
|
262
|
+
borderRadius: "12px",
|
|
263
|
+
boxShadow: "0 10px 25px rgba(0,0,0,0.15)",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
el: ".backY",
|
|
268
|
+
style: {
|
|
269
|
+
background: "#f8f9fa",
|
|
270
|
+
padding: "20px",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Handle back button
|
|
277
|
+
document.addEventListener("click", function (e) {
|
|
278
|
+
if (e.target.classList.contains("back-btn")) {
|
|
279
|
+
const panel = e.target.closest("._justFlipIt_panel");
|
|
280
|
+
if (panel) panel.classList.toggle("_flipY_");
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
</script>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Browser Support
|
|
287
|
+
|
|
288
|
+
- ✅ Chrome 60+
|
|
289
|
+
- ✅ Firefox 55+
|
|
290
|
+
- ✅ Safari 12+
|
|
291
|
+
- ✅ Edge 79+
|
|
292
|
+
- ✅ iOS Safari 12+
|
|
293
|
+
- ✅ Android Chrome 60+
|
|
294
|
+
|
|
295
|
+
## Contributing
|
|
296
|
+
|
|
297
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
**[🌟 Star this project on GitHub](https://github.com/SimHub/justFlipIt)** | **[📦 View on NPM](https://www.npmjs.com/package/justflipit)** | \*\*[🚀 Live Demo
|