@simhub2/justflipit 3.0.1 → 3.1.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 +114 -240
- package/dist/justFlipIt-modern.js +24 -51
- package/dist/justFlipIt-modern.min.js +1 -1
- package/dist/justFlipIt-vanilla.js +30 -37
- package/dist/justFlipIt-vanilla.min.js +1 -1
- package/dist/justFlipIt.js +30 -34
- 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 +30 -34
- package/src/justFlipIt-combined.min.js +1 -1
- package/src/justFlipIt-modern.js +24 -51
- package/src/justFlipIt-modern.min.js +1 -1
- package/src/justFlipIt-vanilla.js +30 -37
- package/src/justFlipIt-vanilla.min.js +1 -1
- package/src/justFlipIt.d.ts +10 -0
|
@@ -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(){"undefined"!=typeof CSS&&CSS.supports&&CSS.supports("display","grid");let a="undefined"!=typeof Element&&"animate"in Element.prototype;window.CSS&&CSS.supports&&CSS.supports("color","var(--test)");function i(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}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(){"undefined"!=typeof CSS&&CSS.supports&&CSS.supports("display","grid");let a="undefined"!=typeof Element&&"animate"in Element.prototype;window.CSS&&CSS.supports&&CSS.supports("color","var(--test)");function i(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function r(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function s(t,e,s,i,r="ease-in-out"){a?t.animate([{transform:e},{transform:s}],{duration:i,easing:r,fill:"forwards"}):(t.style.transform=s,t.style.webkitTransform=s,t.style.mozTransform=s)}let n=new WeakMap;class o{constructor(t,e={}){var s;document.querySelector('[data-justflipitstyle="justFlipIt"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt"),s.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;position:relative;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;transform-style:preserve-3d;backface-visibility:hidden;transition:transform .4s ease-in-out;}._justFlipIt_panel .back, ._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;transform-style:preserve-3d;backface-visibility:hidden;transition:transform .4s ease-in-out;}._justFlipIt_panel .front{-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:transform .4s ease-in-out;-moz-transition:transform .4s ease-in-out;}._justFlipIt_panel .back, ._justFlipIt_panel .backY{-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:transform .4s ease-in-out;-moz-transition:transform .4s ease-in-out;}._justFlipIt_panel .back{transform:rotateX(-180deg);-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);}._justFlipIt_panel._flip_ .front{transform:rotateX(180deg);-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg);}._justFlipIt_panel._flip_ .back{transform:rotateX(0);-webkit-transform:rotateX(0);-moz-transform:rotateX(0);}._justFlipIt_panel .backY{transform:rotateY(-180deg);-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);}._justFlipIt_panel._flipY_ .front{transform:rotateY(180deg);-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg);}._justFlipIt_panel._flipY_ .backY{transform:rotateY(0);-webkit-transform:rotateY(0);-moz-transform:rotateY(0);}._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s)),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=i(t,"width"),this.elementHeight=i(t,"height"),this.elementBackgroundColor=i(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.rotateStart="rotateX(0deg)",this.rotateFront="rotateX(180deg)",this.rotateBack="rotateX(-180deg)",this.rotateReset="rotateX(0deg)"):(this.flipClass="_flipY_",this.backClass="backY",this.rotateStart="rotateY(0deg)",this.rotateFront="rotateY(180deg)",this.rotateBack="rotateY(-180deg)",this.rotateReset="rotateY(0deg)"),this._init(),n.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(r(s,"hover"),r(s,"_justFlipIt_panel"),document.createElement("div")),i=(r(e,"front"),document.createElement("div"));r(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(t){!0===this.settings.Click?t.addEventListener("click",t=>{t.preventDefault(),this._toggleFlip()}):"string"==typeof this.settings.Click?t.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{this._toggleFlip()})}):(t.addEventListener("mouseenter",()=>{this._flip(!0)}),t.addEventListener("mouseleave",()=>{this._flip(!1)}))}_toggleFlip(){t=this.hoverPanel,e=this.flipClass;var t,e=t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className);this._flip(!e)}_flip(t){var e;t?(r(this.hoverPanel,this.flipClass),a&&(s(this.frontWrapper,this.rotateStart,this.rotateFront,this.settings.Duration,this.settings.Easing),s(this.backWrapper,this.rotateBack,this.rotateReset,this.settings.Duration,this.settings.Easing))):(t=this.hoverPanel,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," "),a&&(s(this.frontWrapper,this.rotateFront,this.rotateStart,this.settings.Duration,this.settings.Easing),s(this.backWrapper,this.rotateReset,this.rotateBack,this.settings.Duration,this.settings.Easing)))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),n.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new o(t,e))):t instanceof Element?new o(t,e):t.length?Array.from(t).map(t=>new o(t,e)):void 0}return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=n.get(t);t&&t.destroy()})):t instanceof Element?(e=n.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=n.get(t);t&&t.destroy()})},t});
|
|
@@ -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,51 @@
|
|
|
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)) hoverPanel.classList.add(cls);
|
|
204
|
+
if (frontWrapper && !frontWrapper.classList.contains(cls)) frontWrapper.classList.add(cls);
|
|
205
|
+
if (backWrapper && !backWrapper.classList.contains(cls)) backWrapper.classList.add(cls);
|
|
201
206
|
});
|
|
202
207
|
}
|
|
203
208
|
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
// NEU: Inline-Styles übernehmen (nur auf Panel)
|
|
210
|
+
if (this.settings.preserveStyles && originalElement.getAttribute("style")) {
|
|
211
|
+
hoverPanel.setAttribute("style", (hoverPanel.getAttribute("style") || "") +
|
|
212
|
+
";" + originalElement.getAttribute("style"));
|
|
213
|
+
}
|
|
207
214
|
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
originalElement.style.background = "transparent";
|
|
211
|
-
originalElement.style.backgroundColor = "transparent";
|
|
212
|
-
originalElement.style.backgroundImage = "none";
|
|
213
|
-
originalElement.style.border = "none";
|
|
214
|
-
originalElement.style.borderRadius = "0";
|
|
215
|
-
originalElement.style.boxShadow = "none";
|
|
216
|
-
originalElement.style.outline = "none";
|
|
217
|
-
|
|
218
|
-
// NEU: Wende benutzerdefinierte Animationseinstellungen an
|
|
219
|
-
applyAnimationSettings(
|
|
220
|
-
frontWrapper,
|
|
221
|
-
this.settings.Duration,
|
|
222
|
-
this.settings.Easing,
|
|
223
|
-
);
|
|
224
|
-
applyAnimationSettings(
|
|
225
|
-
backWrapper,
|
|
226
|
-
this.settings.Duration,
|
|
227
|
-
this.settings.Easing,
|
|
228
|
-
);
|
|
215
|
+
// Nur den INHALT übernehmen!
|
|
216
|
+
frontWrapper.innerHTML = originalElement.innerHTML;
|
|
229
217
|
|
|
230
218
|
if (this.settings.Template) {
|
|
231
219
|
backWrapper.innerHTML = this.settings.Template;
|
|
232
220
|
} else {
|
|
233
|
-
backWrapper.
|
|
221
|
+
backWrapper.innerHTML = originalElement.innerHTML;
|
|
234
222
|
}
|
|
223
|
+
|
|
224
|
+
// Panel einfügen und Original entfernen
|
|
235
225
|
originalElement.parentNode.insertBefore(hoverPanel, originalElement);
|
|
236
|
-
frontWrapper.appendChild(originalElement);
|
|
237
226
|
hoverPanel.appendChild(frontWrapper);
|
|
238
227
|
hoverPanel.appendChild(backWrapper);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
});
|
|
243
|
-
}
|
|
228
|
+
originalElement.parentNode.removeChild(originalElement);
|
|
229
|
+
|
|
230
|
+
// Panel-Größe und Styles übernehmen
|
|
244
231
|
hoverPanel.style.width = this.elementWidth;
|
|
245
232
|
hoverPanel.style.height = this.elementHeight;
|
|
233
|
+
|
|
234
|
+
// Custom Styles aus Option anwenden
|
|
246
235
|
if (this.settings.Style && this.settings.Style.length) {
|
|
247
236
|
this.settings.Style.forEach((styleObj) => {
|
|
248
237
|
if (styleObj.el) {
|
|
@@ -257,7 +246,11 @@
|
|
|
257
246
|
}
|
|
258
247
|
});
|
|
259
248
|
}
|
|
249
|
+
|
|
250
|
+
// Events setzen
|
|
260
251
|
this._setupEvents(hoverPanel);
|
|
252
|
+
|
|
253
|
+
// Referenzen speichern
|
|
261
254
|
this.hoverPanel = hoverPanel;
|
|
262
255
|
this.frontWrapper = frontWrapper;
|
|
263
256
|
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/src/justFlipIt.d.ts
CHANGED
|
@@ -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
|
/**
|