@simhub2/justflipit 3.2.2 → 4.0.1

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +258 -91
  4. package/dist/agent.cjs +63 -0
  5. package/dist/agent.cjs.map +7 -0
  6. package/dist/agent.d.cts +4 -0
  7. package/dist/agent.d.mts +4 -0
  8. package/dist/agent.d.ts +4 -0
  9. package/dist/agent.mjs +43 -0
  10. package/dist/agent.mjs.map +7 -0
  11. package/dist/justFlipIt-combined.js +295 -0
  12. package/dist/justFlipIt-combined.min.js +23 -0
  13. package/dist/justFlipIt-modern.js +271 -476
  14. package/dist/justFlipIt-modern.min.js +23 -1
  15. package/dist/justFlipIt-vanilla.js +272 -343
  16. package/dist/justFlipIt-vanilla.min.js +23 -1
  17. package/dist/justFlipIt.cjs +293 -0
  18. package/dist/justFlipIt.cjs.map +7 -0
  19. package/dist/justFlipIt.d.cts +4 -0
  20. package/dist/justFlipIt.d.mts +38 -0
  21. package/dist/justFlipIt.d.ts +38 -0
  22. package/dist/justFlipIt.js +269 -391
  23. package/dist/justFlipIt.js.map +7 -0
  24. package/dist/justFlipIt.min.js +23 -1
  25. package/dist/justFlipIt.min.js.map +7 -0
  26. package/dist/justFlipIt.mjs +272 -0
  27. package/dist/justFlipIt.mjs.map +7 -0
  28. package/dist/react.cjs +55 -0
  29. package/dist/react.cjs.map +7 -0
  30. package/dist/react.d.cts +3 -0
  31. package/dist/react.d.mts +3 -0
  32. package/dist/react.d.ts +3 -0
  33. package/dist/react.mjs +25 -0
  34. package/dist/react.mjs.map +7 -0
  35. package/dist/svelte.cjs +45 -0
  36. package/dist/svelte.cjs.map +7 -0
  37. package/dist/svelte.d.cts +3 -0
  38. package/dist/svelte.d.mts +3 -0
  39. package/dist/svelte.d.ts +3 -0
  40. package/dist/svelte.mjs +15 -0
  41. package/dist/svelte.mjs.map +7 -0
  42. package/dist/types/justFlipIt.d.ts +36 -59
  43. package/dist/vue.cjs +49 -0
  44. package/dist/vue.cjs.map +7 -0
  45. package/dist/vue.d.cts +3 -0
  46. package/dist/vue.d.mts +3 -0
  47. package/dist/vue.d.ts +3 -0
  48. package/dist/vue.mjs +19 -0
  49. package/dist/vue.mjs.map +7 -0
  50. package/package.json +117 -50
  51. package/src/justFlipIt-combined.js +0 -417
  52. package/src/justFlipIt-combined.min.js +0 -1
  53. package/src/justFlipIt-modern.js +0 -500
  54. package/src/justFlipIt-modern.min.js +0 -1
  55. package/src/justFlipIt-vanilla.js +0 -366
  56. package/src/justFlipIt-vanilla.min.js +0 -1
  57. package/src/justFlipIt.d.ts +0 -61
@@ -1,417 +0,0 @@
1
- /*!
2
- * justFlipIt v3.1.0
3
- * https://github.com/SimHub/justFlipIt
4
- *
5
- * Copyright SimHub
6
- * Released under the MIT license
7
- *
8
- * Date: 2025
9
- */
10
-
11
- (function (root, factory) {
12
- if (typeof define === "function" && define.amd) {
13
- define(["jquery"], function (jQuery) {
14
- return factory(jQuery || root.jQuery || root.$);
15
- });
16
- } else if (typeof module === "object" && module.exports) {
17
- var jQuery = typeof window !== "undefined" ? window.jQuery : undefined;
18
- if (!jQuery) {
19
- try {
20
- jQuery = require("jquery");
21
- } catch (e) {
22
- jQuery = null;
23
- }
24
- }
25
- module.exports = factory(jQuery);
26
- } else {
27
- root.justFlipIt = factory(root.jQuery || root.$);
28
- }
29
- })(typeof self !== "undefined" ? self : this, function (jQuery) {
30
- "use strict";
31
-
32
- // PATCH: Verbesserte Style-Kopierfunktion
33
- function copyStyles(src, dest) {
34
- const computed = window.getComputedStyle(src);
35
- const properties = [
36
- "background",
37
- "backgroundColor",
38
- "backgroundImage",
39
- "backgroundPosition",
40
- "backgroundRepeat",
41
- "backgroundSize",
42
- "borderRadius",
43
- "borderTopLeftRadius",
44
- "borderTopRightRadius",
45
- "borderBottomLeftRadius",
46
- "borderBottomRightRadius",
47
- "border",
48
- "borderTop",
49
- "borderRight",
50
- "borderBottom",
51
- "borderLeft",
52
- "boxShadow",
53
- "color",
54
- "opacity",
55
- ];
56
- properties.forEach(function (prop) {
57
- if (
58
- computed[prop] &&
59
- computed[prop] !== "none" &&
60
- computed[prop] !== "initial" &&
61
- computed[prop] !== ""
62
- ) {
63
- dest.style[prop] = computed[prop];
64
- }
65
- });
66
- }
67
-
68
- // NEU: Funktion zur Anwendung der benutzerdefinierten Animationseinstellungen
69
- function applyAnimationSettings(element, duration, easing) {
70
- const transitionValue = `all ${duration / 1000}s ${easing}`;
71
- element.style.transition = transitionValue;
72
- element.style.WebkitTransition = transitionValue;
73
- element.style.MozTransition = transitionValue;
74
- element.style.msTransition = transitionValue;
75
- element.style.OTransition = transitionValue;
76
- }
77
-
78
- function addStyles() {
79
- if (document.querySelector('[data-justflipitstyle="justFlipIt_One"]')) {
80
- return;
81
- }
82
- const styleX = document.createElement("style");
83
- styleX.setAttribute("data-justflipitstyle", "justFlipIt_One");
84
- styleX.textContent =
85
- "._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}" +
86
- "._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}" +
87
- "._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}" +
88
- "._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}" +
89
- "._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}";
90
- const styleY = document.createElement("style");
91
- styleY.setAttribute("data-justflipitstyle", "justFlipIt_Two");
92
- styleY.textContent =
93
- "._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}" +
94
- "._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}" +
95
- "._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}";
96
- const styleTransparent = document.createElement("style");
97
- styleTransparent.setAttribute(
98
- "data-justflipitstyle",
99
- "justFlipIt_Transparent",
100
- );
101
- styleTransparent.textContent =
102
- "._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}" +
103
- "._justFlipIt_panel > * {box-sizing: border-box;}";
104
- document.head.appendChild(styleX);
105
- document.head.appendChild(styleY);
106
- document.head.appendChild(styleTransparent);
107
- }
108
-
109
- function getStyle(element, property) {
110
- return window.getComputedStyle(element, null).getPropertyValue(property);
111
- }
112
- function addClass(element, className) {
113
- if (element.classList) {
114
- element.classList.add(className);
115
- } else {
116
- element.className += " " + className;
117
- }
118
- }
119
- function removeClass(element, className) {
120
- if (element.classList) {
121
- element.classList.remove(className);
122
- } else {
123
- element.className = element.className.replace(
124
- new RegExp(
125
- "(^|\\b)" + className.split(" ").join("|") + "(\\b|$)",
126
- "gi",
127
- ),
128
- " ",
129
- );
130
- }
131
- }
132
- function toggleClass(element, className) {
133
- if (element.classList) {
134
- element.classList.toggle(className);
135
- } else {
136
- var classes = element.className.split(" ");
137
- var existingIndex = classes.indexOf(className);
138
- if (existingIndex >= 0) {
139
- classes.splice(existingIndex, 1);
140
- } else {
141
- classes.push(className);
142
- }
143
- element.className = classes.join(" ");
144
- }
145
- }
146
- function hasClass(element, className) {
147
- if (element.classList) {
148
- return element.classList.contains(className);
149
- } else {
150
- return new RegExp("(^| )" + className + "( |$)", "gi").test(
151
- element.className,
152
- );
153
- }
154
- }
155
-
156
- const instanceMap = new WeakMap();
157
-
158
- class JustFlipIt {
159
- constructor(element, options = {}) {
160
- addStyles();
161
- this.element = element;
162
- this.settings = Object.assign(
163
- {},
164
- {
165
- Template: "",
166
- Click: false,
167
- FlipX: false,
168
- Style: [],
169
- // NEU: Standard-Animationsoptionen
170
- Duration: 400,
171
- Easing: "ease-in-out",
172
- preserveClasses: true, // NEU
173
- preserveStyles: true, // NEU
174
- },
175
- options,
176
- );
177
- this.elementWidth = getStyle(element, "width");
178
- this.elementHeight = getStyle(element, "height");
179
- this.elementBackgroundColor = getStyle(element, "background-color");
180
- this.originalClassName = element.className;
181
- this.originalTagName = element.tagName.toLowerCase();
182
- this.originalId = element.id || "";
183
- if (this.settings.FlipX === true) {
184
- this.flipClass = "_flip_";
185
- this.backClass = "back";
186
- } else {
187
- this.flipClass = "_flipY_";
188
- this.backClass = "backY";
189
- }
190
- this._init();
191
- if (this.settings.Tilt) {
192
- this._setupTilt();
193
- }
194
- instanceMap.set(element, this);
195
- }
196
-
197
- _init() {
198
- const originalElement = this.element;
199
- const originalClassName = this.originalClassName;
200
-
201
- // Panel-Struktur erzeugen
202
- const hoverPanel = document.createElement(this.originalTagName);
203
- addClass(hoverPanel, "hover");
204
- addClass(hoverPanel, "_justFlipIt_panel");
205
- const frontWrapper = document.createElement("div");
206
- addClass(frontWrapper, "front");
207
- const backWrapper = document.createElement("div");
208
- addClass(backWrapper, this.backClass);
209
-
210
- // NEU: Klassen übernehmen (Panel, .front, .backY)
211
- if (this.settings.preserveClasses && originalElement.classList.length) {
212
- originalElement.classList.forEach((cls) => {
213
- if (!hoverPanel.classList.contains(cls)) {
214
- hoverPanel.classList.add(cls);
215
- }
216
- if (frontWrapper && !frontWrapper.classList.contains(cls)) {
217
- frontWrapper.classList.add(cls);
218
- }
219
- if (backWrapper && !backWrapper.classList.contains(cls)) {
220
- backWrapper.classList.add(cls);
221
- }
222
- });
223
- }
224
-
225
- // NEU: Inline-Styles übernehmen (nur auf Panel)
226
- if (
227
- this.settings.preserveStyles && originalElement.getAttribute("style")
228
- ) {
229
- hoverPanel.setAttribute(
230
- "style",
231
- (hoverPanel.getAttribute("style") || "") +
232
- ";" + originalElement.getAttribute("style"),
233
- );
234
- }
235
-
236
- // Nur den INHALT übernehmen!
237
- frontWrapper.innerHTML = originalElement.innerHTML;
238
-
239
- if (this.settings.Template) {
240
- backWrapper.innerHTML = this.settings.Template;
241
- } else {
242
- backWrapper.innerHTML = originalElement.innerHTML;
243
- }
244
-
245
- // Panel einfügen und Original entfernen
246
- originalElement.parentNode.insertBefore(hoverPanel, originalElement);
247
- hoverPanel.appendChild(frontWrapper);
248
- hoverPanel.appendChild(backWrapper);
249
- originalElement.parentNode.removeChild(originalElement);
250
-
251
- // Panel-Größe und Styles übernehmen
252
- hoverPanel.style.width = this.elementWidth;
253
- hoverPanel.style.height = this.elementHeight;
254
-
255
- // Custom Styles aus Option anwenden
256
- if (this.settings.Style && this.settings.Style.length) {
257
- this.settings.Style.forEach((styleObj) => {
258
- if (styleObj.el) {
259
- if (styleObj.el.toLowerCase() === "self") {
260
- Object.assign(hoverPanel.style, styleObj.style);
261
- } else {
262
- const targetElements = hoverPanel.querySelectorAll(styleObj.el);
263
- targetElements.forEach((el) => {
264
- Object.assign(el.style, styleObj.style);
265
- });
266
- }
267
- }
268
- });
269
- }
270
-
271
- // Events setzen
272
- this._setupEvents(hoverPanel);
273
-
274
- // Referenzen speichern
275
- this.hoverPanel = hoverPanel;
276
- this.frontWrapper = frontWrapper;
277
- this.backWrapper = backWrapper;
278
- }
279
-
280
- _setupTilt() {
281
- const handleMove = (e) => {
282
- const rect = this.hoverPanel.getBoundingClientRect();
283
- const x = (e.touches ? e.touches[0].clientX : e.clientX) - rect.left;
284
- const y = (e.touches ? e.touches[0].clientY : e.clientY) - rect.top;
285
- const centerX = rect.width / 2;
286
- const centerY = rect.height / 2;
287
- const rotateX = ((y - centerY) / centerY) * 10;
288
- const rotateY = (-(x - centerX) / centerX) * 10;
289
- this.hoverPanel.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(1.05, 1.05, 1.05)`;
290
- };
291
-
292
- const handleEnter = () => {
293
- this.hoverPanel.style.transition = "all 0.2s ease-out";
294
- };
295
-
296
- const handleLeave = () => {
297
- this.hoverPanel.style.transform = `perspective(1000px) rotateX(0) rotateY(0) scale3d(1, 1, 1)`;
298
- this.hoverPanel.style.transition = "all 0.5s ease-in-out";
299
- };
300
-
301
- this.hoverPanel.addEventListener("mousemove", handleMove);
302
- this.hoverPanel.addEventListener("touchmove", handleMove);
303
- this.hoverPanel.addEventListener("mouseenter", handleEnter);
304
- this.hoverPanel.addEventListener("touchstart", handleEnter);
305
- this.hoverPanel.addEventListener("mouseleave", handleLeave);
306
- this.hoverPanel.addEventListener("touchend", handleLeave);
307
- }
308
-
309
- _setupEvents(hoverPanel) {
310
- if (this.settings.Tilt === 'only') return;
311
- if (this.settings.Click === true) {
312
- hoverPanel.addEventListener("click", (e) => {
313
- e.preventDefault();
314
- toggleClass(hoverPanel, this.flipClass);
315
- });
316
- } else if (typeof this.settings.Click === "string") {
317
- const clickElements = hoverPanel.querySelectorAll(this.settings.Click);
318
- clickElements.forEach((el) => {
319
- el.addEventListener("click", () => {
320
- toggleClass(hoverPanel, this.flipClass);
321
- });
322
- });
323
- } else {
324
- hoverPanel.addEventListener("mouseenter", () => {
325
- addClass(hoverPanel, this.flipClass);
326
- });
327
- hoverPanel.addEventListener("mouseleave", () => {
328
- removeClass(hoverPanel, this.flipClass);
329
- });
330
- }
331
- }
332
-
333
- destroy() {
334
- const hoverPanel = this.hoverPanel;
335
- const originalElement = hoverPanel.querySelector(".front > *");
336
- originalElement.className = this.originalClassName;
337
- hoverPanel.parentNode.insertBefore(originalElement, hoverPanel);
338
- hoverPanel.parentNode.removeChild(hoverPanel);
339
- instanceMap.delete(this.element);
340
- }
341
- }
342
-
343
- // Vanilla/JS API
344
- function justFlipIt(selector, options = {}) {
345
- if (typeof selector === "string") {
346
- const elements = document.querySelectorAll(selector);
347
- return Array.from(elements).map((el) => new JustFlipIt(el, options));
348
- } else if (selector instanceof Element) {
349
- return new JustFlipIt(selector, options);
350
- } else if (selector.length) {
351
- return Array.from(selector).map((el) => new JustFlipIt(el, options));
352
- }
353
- }
354
-
355
- justFlipIt.destroy = function (selector) {
356
- if (typeof selector === "string") {
357
- const elements = document.querySelectorAll(selector);
358
- Array.from(elements).forEach((el) => {
359
- const instance = instanceMap.get(el);
360
- if (instance) instance.destroy();
361
- });
362
- } else if (selector instanceof Element) {
363
- const instance = instanceMap.get(selector);
364
- if (instance) instance.destroy();
365
- } else if (selector.length) {
366
- Array.from(selector).forEach((el) => {
367
- const instance = instanceMap.get(el);
368
- if (instance) instance.destroy();
369
- });
370
- }
371
- };
372
-
373
- // jQuery-Plugin API
374
- if (jQuery) {
375
- jQuery.fn.justFlipIt = function (options) {
376
- return this.each(function () {
377
- if (!jQuery.data(this, "plugin_justFlipIt")) {
378
- jQuery.data(this, "plugin_justFlipIt", new JustFlipIt(this, options));
379
- }
380
- });
381
- };
382
-
383
- jQuery.fn.destroy = function () {
384
- return this.each(function () {
385
- const instance = instanceMap.get(this);
386
- if (instance) {
387
- instance.destroy();
388
- jQuery.removeData(this, "plugin_justFlipIt");
389
- }
390
- });
391
- };
392
-
393
- // jQuery-API als Haupt-Export
394
- var api = function (selector, options) {
395
- if (typeof selector === "string") {
396
- return jQuery(selector).justFlipIt(options);
397
- } else if (selector instanceof Element) {
398
- return jQuery(selector).justFlipIt(options);
399
- } else if (selector instanceof jQuery) {
400
- return selector.justFlipIt(options);
401
- }
402
- };
403
- api.destroy = function (selector) {
404
- if (typeof selector === "string") {
405
- jQuery(selector).destroy();
406
- } else if (selector instanceof Element) {
407
- jQuery(selector).destroy();
408
- } else if (selector instanceof jQuery) {
409
- selector.destroy();
410
- }
411
- };
412
- return api;
413
- }
414
-
415
- // Vanilla-API als Fallback
416
- return justFlipIt;
417
- });
@@ -1 +0,0 @@
1
- (function(root,factory){if(typeof define==="function"&&define.amd){define(["jquery"],function(jQuery){return factory(jQuery||root.jQuery||root.$)})}else if(typeof module==="object"&&module.exports){var jQuery=typeof window!=="undefined"?window.jQuery:undefined;if(!jQuery){try{jQuery=require("jquery")}catch(e){jQuery=null}}module.exports=factory(jQuery)}else{root.justFlipIt=factory(root.jQuery||root.$)}})(typeof self!=="undefined"?self:this,function(jQuery){"use strict";function copyStyles(src,dest){const computed=window.getComputedStyle(src);const properties=["background","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","backgroundSize","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","borderTop","borderRight","borderBottom","borderLeft","boxShadow","color","opacity"];properties.forEach(function(prop){if(computed[prop]&&computed[prop]!=="none"&&computed[prop]!=="initial"&&computed[prop]!==""){dest.style[prop]=computed[prop]}})}function applyAnimationSettings(element,duration,easing){const transitionValue=`all ${duration/1e3}s ${easing}`;element.style.transition=transitionValue;element.style.WebkitTransition=transitionValue;element.style.MozTransition=transitionValue;element.style.msTransition=transitionValue;element.style.OTransition=transitionValue}function addStyles(){if(document.querySelector('[data-justflipitstyle="justFlipIt_One"]')){return}const styleX=document.createElement("style");styleX.setAttribute("data-justflipitstyle","justFlipIt_One");styleX.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}"+"._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}"+"._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}"+"._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}"+"._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}";const styleY=document.createElement("style");styleY.setAttribute("data-justflipitstyle","justFlipIt_Two");styleY.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}"+"._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}"+"._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}";const styleTransparent=document.createElement("style");styleTransparent.setAttribute("data-justflipitstyle","justFlipIt_Transparent");styleTransparent.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}"+"._justFlipIt_panel > * {box-sizing: border-box;}";document.head.appendChild(styleX);document.head.appendChild(styleY);document.head.appendChild(styleTransparent)}function getStyle(element,property){return window.getComputedStyle(element,null).getPropertyValue(property)}function addClass(element,className){if(element.classList){element.classList.add(className)}else{element.className+=" "+className}}function removeClass(element,className){if(element.classList){element.classList.remove(className)}else{element.className=element.className.replace(new RegExp("(^|\\b)"+className.split(" ").join("|")+"(\\b|$)","gi")," ")}}function toggleClass(element,className){if(element.classList){element.classList.toggle(className)}else{var classes=element.className.split(" ");var existingIndex=classes.indexOf(className);if(existingIndex>=0){classes.splice(existingIndex,1)}else{classes.push(className)}element.className=classes.join(" ")}}function hasClass(element,className){if(element.classList){return element.classList.contains(className)}else{return new RegExp("(^| )"+className+"( |$)","gi").test(element.className)}}const instanceMap=new WeakMap;class JustFlipIt{constructor(element,options={}){addStyles();this.element=element;this.settings=Object.assign({},{Template:"",Click:false,FlipX:false,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:true,preserveStyles:true},options);this.elementWidth=getStyle(element,"width");this.elementHeight=getStyle(element,"height");this.elementBackgroundColor=getStyle(element,"background-color");this.originalClassName=element.className;this.originalTagName=element.tagName.toLowerCase();this.originalId=element.id||"";if(this.settings.FlipX===true){this.flipClass="_flip_";this.backClass="back"}else{this.flipClass="_flipY_";this.backClass="backY"}this._init();if(this.settings.Tilt){this._setupTilt()}instanceMap.set(element,this)}_init(){const originalElement=this.element;const originalClassName=this.originalClassName;const hoverPanel=document.createElement(this.originalTagName);addClass(hoverPanel,"hover");addClass(hoverPanel,"_justFlipIt_panel");const frontWrapper=document.createElement("div");addClass(frontWrapper,"front");const backWrapper=document.createElement("div");addClass(backWrapper,this.backClass);if(this.settings.preserveClasses&&originalElement.classList.length){originalElement.classList.forEach(cls=>{if(!hoverPanel.classList.contains(cls)){hoverPanel.classList.add(cls)}if(frontWrapper&&!frontWrapper.classList.contains(cls)){frontWrapper.classList.add(cls)}if(backWrapper&&!backWrapper.classList.contains(cls)){backWrapper.classList.add(cls)}})}if(this.settings.preserveStyles&&originalElement.getAttribute("style")){hoverPanel.setAttribute("style",(hoverPanel.getAttribute("style")||"")+";"+originalElement.getAttribute("style"))}frontWrapper.innerHTML=originalElement.innerHTML;if(this.settings.Template){backWrapper.innerHTML=this.settings.Template}else{backWrapper.innerHTML=originalElement.innerHTML}originalElement.parentNode.insertBefore(hoverPanel,originalElement);hoverPanel.appendChild(frontWrapper);hoverPanel.appendChild(backWrapper);originalElement.parentNode.removeChild(originalElement);hoverPanel.style.width=this.elementWidth;hoverPanel.style.height=this.elementHeight;if(this.settings.Style&&this.settings.Style.length){this.settings.Style.forEach(styleObj=>{if(styleObj.el){if(styleObj.el.toLowerCase()==="self"){Object.assign(hoverPanel.style,styleObj.style)}else{const targetElements=hoverPanel.querySelectorAll(styleObj.el);targetElements.forEach(el=>{Object.assign(el.style,styleObj.style)})}}})}this._setupEvents(hoverPanel);this.hoverPanel=hoverPanel;this.frontWrapper=frontWrapper;this.backWrapper=backWrapper}_setupTilt(){const handleMove=e=>{const rect=this.hoverPanel.getBoundingClientRect();const x=(e.touches?e.touches[0].clientX:e.clientX)-rect.left;const y=(e.touches?e.touches[0].clientY:e.clientY)-rect.top;const centerX=rect.width/2;const centerY=rect.height/2;const rotateX=(y-centerY)/centerY*10;const rotateY=-(x-centerX)/centerX*10;this.hoverPanel.style.transform=`perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(1.05, 1.05, 1.05)`};const handleEnter=()=>{this.hoverPanel.style.transition="all 0.2s ease-out"};const handleLeave=()=>{this.hoverPanel.style.transform=`perspective(1000px) rotateX(0) rotateY(0) scale3d(1, 1, 1)`;this.hoverPanel.style.transition="all 0.5s ease-in-out"};this.hoverPanel.addEventListener("mousemove",handleMove);this.hoverPanel.addEventListener("touchmove",handleMove);this.hoverPanel.addEventListener("mouseenter",handleEnter);this.hoverPanel.addEventListener("touchstart",handleEnter);this.hoverPanel.addEventListener("mouseleave",handleLeave);this.hoverPanel.addEventListener("touchend",handleLeave)}_setupEvents(hoverPanel){if(this.settings.Tilt==="only")return;if(this.settings.Click===true){hoverPanel.addEventListener("click",e=>{e.preventDefault();toggleClass(hoverPanel,this.flipClass)})}else if(typeof this.settings.Click==="string"){const clickElements=hoverPanel.querySelectorAll(this.settings.Click);clickElements.forEach(el=>{el.addEventListener("click",()=>{toggleClass(hoverPanel,this.flipClass)})})}else{hoverPanel.addEventListener("mouseenter",()=>{addClass(hoverPanel,this.flipClass)});hoverPanel.addEventListener("mouseleave",()=>{removeClass(hoverPanel,this.flipClass)})}}destroy(){const hoverPanel=this.hoverPanel;const originalElement=hoverPanel.querySelector(".front > *");originalElement.className=this.originalClassName;hoverPanel.parentNode.insertBefore(originalElement,hoverPanel);hoverPanel.parentNode.removeChild(hoverPanel);instanceMap.delete(this.element)}}function justFlipIt(selector,options={}){if(typeof selector==="string"){const elements=document.querySelectorAll(selector);return Array.from(elements).map(el=>new JustFlipIt(el,options))}else if(selector instanceof Element){return new JustFlipIt(selector,options)}else if(selector.length){return Array.from(selector).map(el=>new JustFlipIt(el,options))}}justFlipIt.destroy=function(selector){if(typeof selector==="string"){const elements=document.querySelectorAll(selector);Array.from(elements).forEach(el=>{const instance=instanceMap.get(el);if(instance)instance.destroy()})}else if(selector instanceof Element){const instance=instanceMap.get(selector);if(instance)instance.destroy()}else if(selector.length){Array.from(selector).forEach(el=>{const instance=instanceMap.get(el);if(instance)instance.destroy()})}};if(jQuery){jQuery.fn.justFlipIt=function(options){return this.each(function(){if(!jQuery.data(this,"plugin_justFlipIt")){jQuery.data(this,"plugin_justFlipIt",new JustFlipIt(this,options))}})};jQuery.fn.destroy=function(){return this.each(function(){const instance=instanceMap.get(this);if(instance){instance.destroy();jQuery.removeData(this,"plugin_justFlipIt")}})};var api=function(selector,options){if(typeof selector==="string"){return jQuery(selector).justFlipIt(options)}else if(selector instanceof Element){return jQuery(selector).justFlipIt(options)}else if(selector instanceof jQuery){return selector.justFlipIt(options)}};api.destroy=function(selector){if(typeof selector==="string"){jQuery(selector).destroy()}else if(selector instanceof Element){jQuery(selector).destroy()}else if(selector instanceof jQuery){selector.destroy()}};return api}return justFlipIt});