@simhub2/justflipit 3.0.1 → 3.1.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.
- package/README.md +121 -236
- package/dist/justFlipIt-modern.js +43 -60
- package/dist/justFlipIt-modern.min.js +1 -1
- package/dist/justFlipIt-vanilla.js +44 -40
- package/dist/justFlipIt-vanilla.min.js +1 -1
- package/dist/justFlipIt.js +45 -38
- package/dist/justFlipIt.min.js +1 -1
- package/dist/types/justFlipIt.d.ts +10 -0
- package/package.json +1 -1
- package/src/justFlipIt-combined.js +45 -38
- package/src/justFlipIt-combined.min.js +1 -1
- package/src/justFlipIt-modern.js +43 -60
- package/src/justFlipIt-modern.min.js +1 -1
- package/src/justFlipIt-vanilla.js +44 -40
- package/src/justFlipIt-vanilla.min.js +1 -1
- package/src/justFlipIt.d.ts +10 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
2
|
+
* justFlipIt v3.1.1
|
|
3
3
|
* https://github.com/SimHub/justFlipIt
|
|
4
4
|
*
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright SimHub
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
*
|
|
8
|
-
* Date:
|
|
8
|
+
* Date: 2025
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
(function (root, factory) {
|
|
@@ -160,9 +160,10 @@
|
|
|
160
160
|
Click: false,
|
|
161
161
|
FlipX: false,
|
|
162
162
|
Style: [],
|
|
163
|
-
// NEU: Standard-Animationsoptionen
|
|
164
163
|
Duration: 400,
|
|
165
164
|
Easing: "ease-in-out",
|
|
165
|
+
preserveClasses: true, // NEU
|
|
166
|
+
preserveStyles: true, // NEU
|
|
166
167
|
},
|
|
167
168
|
options,
|
|
168
169
|
);
|
|
@@ -186,63 +187,62 @@
|
|
|
186
187
|
_init() {
|
|
187
188
|
const originalElement = this.element;
|
|
188
189
|
const originalClassName = this.originalClassName;
|
|
190
|
+
|
|
191
|
+
// Panel-Struktur erzeugen
|
|
189
192
|
const hoverPanel = document.createElement(this.originalTagName);
|
|
190
193
|
addClass(hoverPanel, "hover");
|
|
191
194
|
addClass(hoverPanel, "_justFlipIt_panel");
|
|
192
195
|
const frontWrapper = document.createElement("div");
|
|
193
196
|
addClass(frontWrapper, "front");
|
|
194
|
-
const clone = originalElement.cloneNode(true);
|
|
195
|
-
clone.className = "";
|
|
196
197
|
const backWrapper = document.createElement("div");
|
|
197
198
|
addClass(backWrapper, this.backClass);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
|
|
200
|
+
// NEU: Klassen übernehmen (Panel, .front, .backY)
|
|
201
|
+
if (this.settings.preserveClasses && originalElement.classList.length) {
|
|
202
|
+
originalElement.classList.forEach((cls) => {
|
|
203
|
+
if (!hoverPanel.classList.contains(cls)) {
|
|
204
|
+
hoverPanel.classList.add(cls);
|
|
205
|
+
}
|
|
206
|
+
if (frontWrapper && !frontWrapper.classList.contains(cls)) {
|
|
207
|
+
frontWrapper.classList.add(cls);
|
|
208
|
+
}
|
|
209
|
+
if (backWrapper && !backWrapper.classList.contains(cls)) {
|
|
210
|
+
backWrapper.classList.add(cls);
|
|
211
|
+
}
|
|
201
212
|
});
|
|
202
213
|
}
|
|
203
214
|
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
originalElement.style.borderRadius = "0";
|
|
215
|
-
originalElement.style.boxShadow = "none";
|
|
216
|
-
originalElement.style.outline = "none";
|
|
215
|
+
// NEU: Inline-Styles übernehmen (nur auf Panel)
|
|
216
|
+
if (
|
|
217
|
+
this.settings.preserveStyles && originalElement.getAttribute("style")
|
|
218
|
+
) {
|
|
219
|
+
hoverPanel.setAttribute(
|
|
220
|
+
"style",
|
|
221
|
+
(hoverPanel.getAttribute("style") || "") +
|
|
222
|
+
";" + originalElement.getAttribute("style"),
|
|
223
|
+
);
|
|
224
|
+
}
|
|
217
225
|
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
frontWrapper,
|
|
221
|
-
this.settings.Duration,
|
|
222
|
-
this.settings.Easing,
|
|
223
|
-
);
|
|
224
|
-
applyAnimationSettings(
|
|
225
|
-
backWrapper,
|
|
226
|
-
this.settings.Duration,
|
|
227
|
-
this.settings.Easing,
|
|
228
|
-
);
|
|
226
|
+
// Nur den INHALT übernehmen!
|
|
227
|
+
frontWrapper.innerHTML = originalElement.innerHTML;
|
|
229
228
|
|
|
230
229
|
if (this.settings.Template) {
|
|
231
230
|
backWrapper.innerHTML = this.settings.Template;
|
|
232
231
|
} else {
|
|
233
|
-
backWrapper.
|
|
232
|
+
backWrapper.innerHTML = originalElement.innerHTML;
|
|
234
233
|
}
|
|
234
|
+
|
|
235
|
+
// Panel einfügen und Original entfernen
|
|
235
236
|
originalElement.parentNode.insertBefore(hoverPanel, originalElement);
|
|
236
|
-
frontWrapper.appendChild(originalElement);
|
|
237
237
|
hoverPanel.appendChild(frontWrapper);
|
|
238
238
|
hoverPanel.appendChild(backWrapper);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
});
|
|
243
|
-
}
|
|
239
|
+
originalElement.parentNode.removeChild(originalElement);
|
|
240
|
+
|
|
241
|
+
// Panel-Größe und Styles übernehmen
|
|
244
242
|
hoverPanel.style.width = this.elementWidth;
|
|
245
243
|
hoverPanel.style.height = this.elementHeight;
|
|
244
|
+
|
|
245
|
+
// Custom Styles aus Option anwenden
|
|
246
246
|
if (this.settings.Style && this.settings.Style.length) {
|
|
247
247
|
this.settings.Style.forEach((styleObj) => {
|
|
248
248
|
if (styleObj.el) {
|
|
@@ -257,7 +257,11 @@
|
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
+
|
|
261
|
+
// Events setzen
|
|
260
262
|
this._setupEvents(hoverPanel);
|
|
263
|
+
|
|
264
|
+
// Referenzen speichern
|
|
261
265
|
this.hoverPanel = hoverPanel;
|
|
262
266
|
this.frontWrapper = frontWrapper;
|
|
263
267
|
this.backWrapper = backWrapper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
((t,e)=>{"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.justFlipIt=e()})("undefined"!=typeof self?self:this,function(){function
|
|
1
|
+
((t,e)=>{"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.justFlipIt=e()})("undefined"!=typeof self?self:this,function(){function n(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function a(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let l=new WeakMap;class i{constructor(t,e={}){var s,i,a;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.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)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.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)}",(a=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),a.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(a)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=n(t,"width"),this.elementHeight=n(t,"height"),this.elementBackgroundColor=n(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),l.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(a(s,"hover"),a(s,"_justFlipIt_panel"),document.createElement("div")),i=(a(e,"front"),document.createElement("div"));a(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{a(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),l.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=l.get(t);t&&t.destroy()})):t instanceof Element?(e=l.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=l.get(t);t&&t.destroy()})},t});
|
package/dist/justFlipIt.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* justFlipIt v3.
|
|
1
|
+
/*5
|
|
2
|
+
* justFlipIt v3.1.1
|
|
3
3
|
* https://github.com/SimHub/justFlipIt
|
|
4
4
|
*
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright SimHub
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
*
|
|
8
|
-
* Date:
|
|
8
|
+
* Date: 2025
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
(function (root, factory) {
|
|
@@ -169,6 +169,8 @@
|
|
|
169
169
|
// NEU: Standard-Animationsoptionen
|
|
170
170
|
Duration: 400,
|
|
171
171
|
Easing: "ease-in-out",
|
|
172
|
+
preserveClasses: true, // NEU
|
|
173
|
+
preserveStyles: true, // NEU
|
|
172
174
|
},
|
|
173
175
|
options,
|
|
174
176
|
);
|
|
@@ -192,61 +194,62 @@
|
|
|
192
194
|
_init() {
|
|
193
195
|
const originalElement = this.element;
|
|
194
196
|
const originalClassName = this.originalClassName;
|
|
197
|
+
|
|
198
|
+
// Panel-Struktur erzeugen
|
|
195
199
|
const hoverPanel = document.createElement(this.originalTagName);
|
|
196
200
|
addClass(hoverPanel, "hover");
|
|
197
201
|
addClass(hoverPanel, "_justFlipIt_panel");
|
|
198
202
|
const frontWrapper = document.createElement("div");
|
|
199
203
|
addClass(frontWrapper, "front");
|
|
200
|
-
const clone = originalElement.cloneNode(true);
|
|
201
|
-
clone.className = "";
|
|
202
204
|
const backWrapper = document.createElement("div");
|
|
203
205
|
addClass(backWrapper, this.backClass);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
|
|
207
|
+
// NEU: Klassen übernehmen (Panel, .front, .backY)
|
|
208
|
+
if (this.settings.preserveClasses && originalElement.classList.length) {
|
|
209
|
+
originalElement.classList.forEach((cls) => {
|
|
210
|
+
if (!hoverPanel.classList.contains(cls)) {
|
|
211
|
+
hoverPanel.classList.add(cls);
|
|
212
|
+
}
|
|
213
|
+
if (frontWrapper && !frontWrapper.classList.contains(cls)) {
|
|
214
|
+
frontWrapper.classList.add(cls);
|
|
215
|
+
}
|
|
216
|
+
if (backWrapper && !backWrapper.classList.contains(cls)) {
|
|
217
|
+
backWrapper.classList.add(cls);
|
|
218
|
+
}
|
|
207
219
|
});
|
|
208
220
|
}
|
|
209
221
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
originalElement.style.outline = "none";
|
|
222
|
+
// NEU: Inline-Styles übernehmen (nur auf Panel)
|
|
223
|
+
if (
|
|
224
|
+
this.settings.preserveStyles && originalElement.getAttribute("style")
|
|
225
|
+
) {
|
|
226
|
+
hoverPanel.setAttribute(
|
|
227
|
+
"style",
|
|
228
|
+
(hoverPanel.getAttribute("style") || "") +
|
|
229
|
+
";" + originalElement.getAttribute("style"),
|
|
230
|
+
);
|
|
231
|
+
}
|
|
221
232
|
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
frontWrapper,
|
|
225
|
-
this.settings.Duration,
|
|
226
|
-
this.settings.Easing,
|
|
227
|
-
);
|
|
228
|
-
applyAnimationSettings(
|
|
229
|
-
backWrapper,
|
|
230
|
-
this.settings.Duration,
|
|
231
|
-
this.settings.Easing,
|
|
232
|
-
);
|
|
233
|
+
// Nur den INHALT übernehmen!
|
|
234
|
+
frontWrapper.innerHTML = originalElement.innerHTML;
|
|
233
235
|
|
|
234
236
|
if (this.settings.Template) {
|
|
235
237
|
backWrapper.innerHTML = this.settings.Template;
|
|
236
238
|
} else {
|
|
237
|
-
backWrapper.
|
|
239
|
+
backWrapper.innerHTML = originalElement.innerHTML;
|
|
238
240
|
}
|
|
241
|
+
|
|
242
|
+
// Panel einfügen und Original entfernen
|
|
239
243
|
originalElement.parentNode.insertBefore(hoverPanel, originalElement);
|
|
240
|
-
frontWrapper.appendChild(originalElement);
|
|
241
244
|
hoverPanel.appendChild(frontWrapper);
|
|
242
245
|
hoverPanel.appendChild(backWrapper);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
246
|
+
originalElement.parentNode.removeChild(originalElement);
|
|
247
|
+
|
|
248
|
+
// Panel-Größe und Styles übernehmen
|
|
248
249
|
hoverPanel.style.width = this.elementWidth;
|
|
249
250
|
hoverPanel.style.height = this.elementHeight;
|
|
251
|
+
|
|
252
|
+
// Custom Styles aus Option anwenden
|
|
250
253
|
if (this.settings.Style && this.settings.Style.length) {
|
|
251
254
|
this.settings.Style.forEach((styleObj) => {
|
|
252
255
|
if (styleObj.el) {
|
|
@@ -261,7 +264,11 @@
|
|
|
261
264
|
}
|
|
262
265
|
});
|
|
263
266
|
}
|
|
267
|
+
|
|
268
|
+
// Events setzen
|
|
264
269
|
this._setupEvents(hoverPanel);
|
|
270
|
+
|
|
271
|
+
// Referenzen speichern
|
|
265
272
|
this.hoverPanel = hoverPanel;
|
|
266
273
|
this.frontWrapper = frontWrapper;
|
|
267
274
|
this.backWrapper = backWrapper;
|
package/dist/justFlipIt.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
((e,
|
|
1
|
+
((e,s)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return s(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var i="undefined"!=typeof window?window.jQuery:void 0;if(!i)try{i=require("jquery")}catch(t){i=null}module.exports=s(i)}else e.justFlipIt=s(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(s){function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function n(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let r=new WeakMap;class i{constructor(t,e={}){var s,i,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.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)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.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)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),r.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(n(s,"hover"),n(s,"_justFlipIt_panel"),document.createElement("div")),i=(n(e,"front"),document.createElement("div"));n(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{n(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),r.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}var l;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=r.get(t);t&&t.destroy()})):t instanceof Element?(e=r.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=r.get(t);t&&t.destroy()})},s?(s.fn.justFlipIt=function(t){return this.each(function(){s.data(this,"plugin_justFlipIt")||s.data(this,"plugin_justFlipIt",new i(this,t))})},s.fn.destroy=function(){return this.each(function(){var t=r.get(this);t&&(t.destroy(),s.removeData(this,"plugin_justFlipIt"))})},(l=function(t,e){return"string"==typeof t||t instanceof Element?s(t).justFlipIt(e):t instanceof s?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?s(t).destroy():t instanceof s&&t.destroy()},l):t});
|
|
@@ -24,6 +24,16 @@ declare namespace justFlipIt {
|
|
|
24
24
|
* Custom styles to apply to elements
|
|
25
25
|
*/
|
|
26
26
|
Style?: StyleOption[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* If true, all CSS classes from the original element are copied to the flip panel (default: true)
|
|
30
|
+
*/
|
|
31
|
+
preserveClasses?: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* If true, all inline styles from the original element are copied to the flip panel (default: true)
|
|
35
|
+
*/
|
|
36
|
+
preserveStyles?: boolean;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simhub2/justflipit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "A lightweight JavaScript library that allows you to implement CSS3 based flip animations on any DOM elements",
|
|
5
5
|
"main": "dist/justFlipIt.js",
|
|
6
6
|
"module": "dist/justFlipIt.js",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* justFlipIt v3.
|
|
1
|
+
/*5
|
|
2
|
+
* justFlipIt v3.1.1
|
|
3
3
|
* https://github.com/SimHub/justFlipIt
|
|
4
4
|
*
|
|
5
|
-
* Copyright
|
|
5
|
+
* Copyright SimHub
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
*
|
|
8
|
-
* Date:
|
|
8
|
+
* Date: 2025
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
(function (root, factory) {
|
|
@@ -169,6 +169,8 @@
|
|
|
169
169
|
// NEU: Standard-Animationsoptionen
|
|
170
170
|
Duration: 400,
|
|
171
171
|
Easing: "ease-in-out",
|
|
172
|
+
preserveClasses: true, // NEU
|
|
173
|
+
preserveStyles: true, // NEU
|
|
172
174
|
},
|
|
173
175
|
options,
|
|
174
176
|
);
|
|
@@ -192,61 +194,62 @@
|
|
|
192
194
|
_init() {
|
|
193
195
|
const originalElement = this.element;
|
|
194
196
|
const originalClassName = this.originalClassName;
|
|
197
|
+
|
|
198
|
+
// Panel-Struktur erzeugen
|
|
195
199
|
const hoverPanel = document.createElement(this.originalTagName);
|
|
196
200
|
addClass(hoverPanel, "hover");
|
|
197
201
|
addClass(hoverPanel, "_justFlipIt_panel");
|
|
198
202
|
const frontWrapper = document.createElement("div");
|
|
199
203
|
addClass(frontWrapper, "front");
|
|
200
|
-
const clone = originalElement.cloneNode(true);
|
|
201
|
-
clone.className = "";
|
|
202
204
|
const backWrapper = document.createElement("div");
|
|
203
205
|
addClass(backWrapper, this.backClass);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
|
|
207
|
+
// NEU: Klassen übernehmen (Panel, .front, .backY)
|
|
208
|
+
if (this.settings.preserveClasses && originalElement.classList.length) {
|
|
209
|
+
originalElement.classList.forEach((cls) => {
|
|
210
|
+
if (!hoverPanel.classList.contains(cls)) {
|
|
211
|
+
hoverPanel.classList.add(cls);
|
|
212
|
+
}
|
|
213
|
+
if (frontWrapper && !frontWrapper.classList.contains(cls)) {
|
|
214
|
+
frontWrapper.classList.add(cls);
|
|
215
|
+
}
|
|
216
|
+
if (backWrapper && !backWrapper.classList.contains(cls)) {
|
|
217
|
+
backWrapper.classList.add(cls);
|
|
218
|
+
}
|
|
207
219
|
});
|
|
208
220
|
}
|
|
209
221
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
originalElement.style.outline = "none";
|
|
222
|
+
// NEU: Inline-Styles übernehmen (nur auf Panel)
|
|
223
|
+
if (
|
|
224
|
+
this.settings.preserveStyles && originalElement.getAttribute("style")
|
|
225
|
+
) {
|
|
226
|
+
hoverPanel.setAttribute(
|
|
227
|
+
"style",
|
|
228
|
+
(hoverPanel.getAttribute("style") || "") +
|
|
229
|
+
";" + originalElement.getAttribute("style"),
|
|
230
|
+
);
|
|
231
|
+
}
|
|
221
232
|
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
frontWrapper,
|
|
225
|
-
this.settings.Duration,
|
|
226
|
-
this.settings.Easing,
|
|
227
|
-
);
|
|
228
|
-
applyAnimationSettings(
|
|
229
|
-
backWrapper,
|
|
230
|
-
this.settings.Duration,
|
|
231
|
-
this.settings.Easing,
|
|
232
|
-
);
|
|
233
|
+
// Nur den INHALT übernehmen!
|
|
234
|
+
frontWrapper.innerHTML = originalElement.innerHTML;
|
|
233
235
|
|
|
234
236
|
if (this.settings.Template) {
|
|
235
237
|
backWrapper.innerHTML = this.settings.Template;
|
|
236
238
|
} else {
|
|
237
|
-
backWrapper.
|
|
239
|
+
backWrapper.innerHTML = originalElement.innerHTML;
|
|
238
240
|
}
|
|
241
|
+
|
|
242
|
+
// Panel einfügen und Original entfernen
|
|
239
243
|
originalElement.parentNode.insertBefore(hoverPanel, originalElement);
|
|
240
|
-
frontWrapper.appendChild(originalElement);
|
|
241
244
|
hoverPanel.appendChild(frontWrapper);
|
|
242
245
|
hoverPanel.appendChild(backWrapper);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
246
|
+
originalElement.parentNode.removeChild(originalElement);
|
|
247
|
+
|
|
248
|
+
// Panel-Größe und Styles übernehmen
|
|
248
249
|
hoverPanel.style.width = this.elementWidth;
|
|
249
250
|
hoverPanel.style.height = this.elementHeight;
|
|
251
|
+
|
|
252
|
+
// Custom Styles aus Option anwenden
|
|
250
253
|
if (this.settings.Style && this.settings.Style.length) {
|
|
251
254
|
this.settings.Style.forEach((styleObj) => {
|
|
252
255
|
if (styleObj.el) {
|
|
@@ -261,7 +264,11 @@
|
|
|
261
264
|
}
|
|
262
265
|
});
|
|
263
266
|
}
|
|
267
|
+
|
|
268
|
+
// Events setzen
|
|
264
269
|
this._setupEvents(hoverPanel);
|
|
270
|
+
|
|
271
|
+
// Referenzen speichern
|
|
265
272
|
this.hoverPanel = hoverPanel;
|
|
266
273
|
this.frontWrapper = frontWrapper;
|
|
267
274
|
this.backWrapper = backWrapper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
((e,
|
|
1
|
+
((e,s)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return s(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var i="undefined"!=typeof window?window.jQuery:void 0;if(!i)try{i=require("jquery")}catch(t){i=null}module.exports=s(i)}else e.justFlipIt=s(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(s){function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function n(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let r=new WeakMap;class i{constructor(t,e={}){var s,i,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.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)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.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)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),r.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(n(s,"hover"),n(s,"_justFlipIt_panel"),document.createElement("div")),i=(n(e,"front"),document.createElement("div"));n(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{n(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),r.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}var l;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=r.get(t);t&&t.destroy()})):t instanceof Element?(e=r.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=r.get(t);t&&t.destroy()})},s?(s.fn.justFlipIt=function(t){return this.each(function(){s.data(this,"plugin_justFlipIt")||s.data(this,"plugin_justFlipIt",new i(this,t))})},s.fn.destroy=function(){return this.each(function(){var t=r.get(this);t&&(t.destroy(),s.removeData(this,"plugin_justFlipIt"))})},(l=function(t,e){return"string"==typeof t||t instanceof Element?s(t).justFlipIt(e):t instanceof s?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?s(t).destroy():t instanceof s&&t.destroy()},l):t});
|