reveal.js-appearance 1.2.1 → 1.3.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/CHANGELOG.md +10 -0
- package/README.md +45 -12
- package/package.json +64 -20
- package/plugin/appearance/appearance.css +120 -202
- package/plugin/appearance/appearance.esm.js +8 -493
- package/plugin/appearance/appearance.js +8 -501
- package/css/demo.css +0 -187
- package/demo-markdown.html +0 -62
- package/demo.html +0 -391
- package/img/1.jpg +0 -0
- package/img/2.jpg +0 -0
- package/img/3.jpg +0 -0
- package/img/4.jpg +0 -0
- package/img/5.jpg +0 -0
- package/markdown.md +0 -156
- package/plugin/appearance/plugin-src.js +0 -458
- package/screenshot.png +0 -0
|
@@ -1,508 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
/*****************************************************************
|
|
3
|
-
* @author: Martijn De Jongh (Martino), martijn.de.jongh@gmail.com
|
|
4
|
-
* https://github.com/Martinomagnifico
|
|
5
2
|
*
|
|
6
|
-
* Appearance
|
|
7
|
-
* Version 1.
|
|
3
|
+
* Appearance for Reveal.js
|
|
4
|
+
* Version 1.3.1
|
|
8
5
|
*
|
|
6
|
+
* @author: Martijn De Jongh (Martino), martijn.de.jongh@gmail.com
|
|
7
|
+
* https://github.com/martinomagnifico
|
|
8
|
+
*
|
|
9
9
|
* @license
|
|
10
10
|
* MIT licensed
|
|
11
|
+
*
|
|
12
|
+
* Copyright (C) 2023 Martijn De Jongh (Martino)
|
|
11
13
|
*
|
|
12
|
-
* Thanks to:
|
|
13
|
-
* - Hakim El Hattab, Reveal.js
|
|
14
|
-
* - Daniel Eden, Animate.css
|
|
15
14
|
******************************************************************/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(function (global, factory) {
|
|
20
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
21
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
22
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Appearance = factory());
|
|
23
|
-
})(this, (function () { 'use strict';
|
|
24
|
-
|
|
25
|
-
const Plugin = () => {
|
|
26
|
-
// Scope support polyfill
|
|
27
|
-
try {
|
|
28
|
-
document.querySelector(":scope *");
|
|
29
|
-
} catch (t) {
|
|
30
|
-
!function (t) {
|
|
31
|
-
let e = /:scope(?![\w-])/gi,
|
|
32
|
-
r = u(t.querySelector);
|
|
33
|
-
|
|
34
|
-
t.querySelector = function (t) {
|
|
35
|
-
return r.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
let c = u(t.querySelectorAll);
|
|
39
|
-
|
|
40
|
-
if (t.querySelectorAll = function (t) {
|
|
41
|
-
return c.apply(this, arguments);
|
|
42
|
-
}, t.matches) {
|
|
43
|
-
let n = u(t.matches);
|
|
44
|
-
|
|
45
|
-
t.matches = function (t) {
|
|
46
|
-
return n.apply(this, arguments);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (t.closest) {
|
|
51
|
-
let o = u(t.closest);
|
|
52
|
-
|
|
53
|
-
t.closest = function (t) {
|
|
54
|
-
return o.apply(this, arguments);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function u(t) {
|
|
59
|
-
return function (r) {
|
|
60
|
-
if (r && e.test(r)) {
|
|
61
|
-
let c = "q" + Math.floor(9e6 * Math.random()) + 1e6;
|
|
62
|
-
arguments[0] = r.replace(e, "[" + c + "]"), this.setAttribute(c, "");
|
|
63
|
-
let n = t.apply(this, arguments);
|
|
64
|
-
return this.removeAttribute(c), n;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return t.apply(this, arguments);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}(Element.prototype);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const loadStyle = function (url, type, callback) {
|
|
74
|
-
let head = document.querySelector('head');
|
|
75
|
-
let style;
|
|
76
|
-
style = document.createElement('link');
|
|
77
|
-
style.rel = 'stylesheet';
|
|
78
|
-
style.href = url;
|
|
79
|
-
|
|
80
|
-
let finish = function () {
|
|
81
|
-
if (typeof callback === 'function') {
|
|
82
|
-
callback.call();
|
|
83
|
-
callback = null;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
style.onload = finish;
|
|
88
|
-
|
|
89
|
-
style.onreadystatechange = function () {
|
|
90
|
-
if (this.readyState === 'loaded') {
|
|
91
|
-
finish();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
head.appendChild(style);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const isJSON = str => {
|
|
99
|
-
try {
|
|
100
|
-
return JSON.parse(str) && !!str;
|
|
101
|
-
} catch (e) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const selectionArray = function (container, selectors) {
|
|
107
|
-
let selections = container.querySelectorAll(selectors);
|
|
108
|
-
let selectionarray = Array.prototype.slice.call(selections);
|
|
109
|
-
return selectionarray;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const isStack = function (section) {
|
|
113
|
-
let isStack = false;
|
|
114
|
-
|
|
115
|
-
for (let i = 0; i < section.childNodes.length; i++) {
|
|
116
|
-
if (section.childNodes[i].tagName == "SECTION") {
|
|
117
|
-
isStack = true;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return isStack;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
function copyDataAttributes(source, target, not) {
|
|
126
|
-
[...source.attributes].filter(attr => attr.nodeName.indexOf('data') > -1).forEach(attr => {
|
|
127
|
-
if (not && attr.nodeName !== not || !not) {
|
|
128
|
-
target.setAttribute(attr.nodeName, attr.nodeValue);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const appear = function (deck, options) {
|
|
134
|
-
let baseclass = 'animate__animated';
|
|
135
|
-
let viewport = deck.getRevealElement().tagName == "BODY" ? document : deck.getRevealElement();
|
|
136
|
-
let appearanceSelector = options.compatibility ? `.${options.compatibilitybaseclass}` : `.${baseclass}`;
|
|
137
|
-
let fragmentSelector = ".fragment";
|
|
138
|
-
let speedClasses = ['slower', 'slow', 'fast', 'faster'];
|
|
139
|
-
speedClasses.push(...speedClasses.map(speed => `animate__${speed}`));
|
|
140
|
-
document.querySelector('[name=generator]');
|
|
141
|
-
const sections = selectionArray(viewport, "section");
|
|
142
|
-
const regularSections = sections.filter(section => !isStack(section) && section.dataset.visibility != "hidden");
|
|
143
|
-
const fragments = deck.getRevealElement().querySelectorAll(fragmentSelector);
|
|
144
|
-
let animatecss = '[class^="animate__"],[class*=" animate__"]';
|
|
145
|
-
|
|
146
|
-
const debugLog = function (text) {
|
|
147
|
-
if (options.debug) console.log(text);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
let url = new URL(window.location);
|
|
151
|
-
let urlparams = new URLSearchParams(url.search);
|
|
152
|
-
|
|
153
|
-
if (urlparams.has('receiver')) {
|
|
154
|
-
viewport.classList.add('sv');
|
|
155
|
-
console.log(viewport);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const assignAutoClass = (section, str, kind) => {
|
|
159
|
-
let index = [...section.parentElement.children].filter(s => s.tagName == "SECTION").indexOf(section) + 1;
|
|
160
|
-
let warning = kind == 'global' ? `JSON Parse error, please try to correct the global "autoelements" option.` : `JSON Parse error, please try to correct the "data-autoappear" attribute on section ${index}`;
|
|
161
|
-
if (typeof str === "string") str = str.replace(/[“”]/g, '"').replace(/[‘’]/g, "'");
|
|
162
|
-
let strJSON = isJSON(str) ? str : typeof str === "object" ? JSON.stringify(str, null, 2) : str.trim().replace(/'/g, '"').charAt(0) === "{" ? str.trim().replace(/'/g, '"') : `{${str.trim().replace(/'/g, '"')}}`;
|
|
163
|
-
|
|
164
|
-
if (!isJSON(strJSON)) {
|
|
165
|
-
console.log(warning);
|
|
166
|
-
} else {
|
|
167
|
-
let elementsToAnimate = JSON.parse(strJSON);
|
|
168
|
-
|
|
169
|
-
for (const [element, assignables] of Object.entries(elementsToAnimate)) {
|
|
170
|
-
let elementsInSection = section.querySelectorAll(element);
|
|
171
|
-
elementsInSection.forEach(elementInSection => {
|
|
172
|
-
if (!elementInSection.classList.contains(baseclass) || elementInSection.dataset["autoappear"]) {
|
|
173
|
-
elementInSection.dataset["autoappear"] = true;
|
|
174
|
-
let newClasses = [],
|
|
175
|
-
newDelay = null,
|
|
176
|
-
speedClass = false;
|
|
177
|
-
|
|
178
|
-
if (Array.isArray(assignables)) {
|
|
179
|
-
newClasses = assignables[0].split(/[ ,]+/);
|
|
180
|
-
newDelay = assignables[1];
|
|
181
|
-
} else if (typeof assignables == "string") {
|
|
182
|
-
newClasses = assignables.split(/[ ,]+/);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
speedClasses.forEach(speed => {
|
|
186
|
-
if (elementInSection.classList.contains(speed)) {
|
|
187
|
-
speedClass = speed;
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
let classesToRemove = [];
|
|
191
|
-
elementInSection.classList.forEach(currentClass => {
|
|
192
|
-
if (String(currentClass).includes("animate__")) {
|
|
193
|
-
classesToRemove.push(currentClass);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
classesToRemove.forEach(currentClass => {
|
|
197
|
-
elementInSection.classList.remove(currentClass);
|
|
198
|
-
});
|
|
199
|
-
newClasses.forEach(newClass => {
|
|
200
|
-
if (speedClasses.includes(newClass)) {
|
|
201
|
-
// There is a speed class from JSON to be assigned
|
|
202
|
-
if (speedClass) {
|
|
203
|
-
speedClass = newClass;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
newClasses.forEach(newClass => {
|
|
208
|
-
elementInSection.classList.add(newClass);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
if (speedClass) {
|
|
212
|
-
elementInSection.classList.add(speedClass);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (newDelay) {
|
|
216
|
-
elementInSection.dataset.delay = newDelay;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
elementInSection.classList.add(baseclass);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const findAppearancesIn = function (container, includeClass, excludeClass) {
|
|
227
|
-
if (!isStack(container)) {
|
|
228
|
-
let appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
229
|
-
appearances.forEach(appearance => {
|
|
230
|
-
let convertListItem = appearance => {
|
|
231
|
-
let from = appearance,
|
|
232
|
-
to = appearance.parentNode;
|
|
233
|
-
if (!to) return;
|
|
234
|
-
|
|
235
|
-
for (let sibling of to.children) {
|
|
236
|
-
if (sibling !== appearance) {
|
|
237
|
-
if (sibling.dataset.appearParent) return;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
to.classList = from.classList;
|
|
242
|
-
copyDataAttributes(from, to, "data-appear-parent");
|
|
243
|
-
to.innerHTML = from.innerHTML;
|
|
244
|
-
}; // Conversion of list items with Appearance classes to the parent, needs manual attribute
|
|
245
|
-
// Relates to Quarto wrapping list content in a span.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (appearance.hasAttribute("data-appear-parent")) {
|
|
249
|
-
convertListItem(appearance);
|
|
250
|
-
} // Automatic conversion of list items which directly contain spans.
|
|
251
|
-
// Relates to Quarto wrapping list content in a span.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (options.appearparents) {
|
|
255
|
-
if (appearance.parentNode && appearance.parentNode.tagName) {
|
|
256
|
-
if (appearance.tagName == "SPAN" && appearance.parentNode.tagName == "LI") {
|
|
257
|
-
let spanLength = String(appearance.outerHTML).length;
|
|
258
|
-
let liContentLength = String(appearance.parentNode.innerHTML).length;
|
|
259
|
-
|
|
260
|
-
if (spanLength == liContentLength) {
|
|
261
|
-
convertListItem(appearance);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
268
|
-
let excludes = selectionArray(container, `:scope ${excludeClass} ${includeClass}`);
|
|
269
|
-
let delay = 0;
|
|
270
|
-
appearances.filter(function (appearance, index) {
|
|
271
|
-
if (!(excludes.indexOf(appearance) > -1)) {
|
|
272
|
-
if (index == 0 && appearance.dataset.delay || index != 0) {
|
|
273
|
-
let elementDelay = options.delay;
|
|
274
|
-
|
|
275
|
-
if (appearance.dataset && appearance.dataset.delay) {
|
|
276
|
-
elementDelay = parseInt(appearance.dataset.delay);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
delay = delay + elementDelay; // Allow fragments to be Appearance items
|
|
280
|
-
|
|
281
|
-
if (appearance.classList.contains("fragment")) {
|
|
282
|
-
delay = 0;
|
|
283
|
-
|
|
284
|
-
if (appearance.querySelectorAll(`.${baseclass}`)) {
|
|
285
|
-
let firstNestedAppearance = appearance.querySelectorAll(`.${baseclass}`)[0];
|
|
286
|
-
|
|
287
|
-
if (firstNestedAppearance) {
|
|
288
|
-
let elementDelay = options.delay;
|
|
289
|
-
|
|
290
|
-
if (firstNestedAppearance.dataset && firstNestedAppearance.dataset.delay) {
|
|
291
|
-
elementDelay = parseInt(firstNestedAppearance.dataset.delay);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
firstNestedAppearance.dataset.delay = elementDelay;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
appearance.style.setProperty('animation-delay', delay + "ms");
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const autoAdd = function () {
|
|
307
|
-
regularSections.forEach(section => {
|
|
308
|
-
if (section.hasAttribute("data-autoappear")) {
|
|
309
|
-
let sectDataAppear = section.dataset.autoappear;
|
|
310
|
-
|
|
311
|
-
if (sectDataAppear == "auto" || sectDataAppear == "" || sectDataAppear.length < 1 || sectDataAppear == "true") {
|
|
312
|
-
// This section should get the global autoappear classes on its objects
|
|
313
|
-
if (options.autoelements) {
|
|
314
|
-
if (!options.autoelements) {
|
|
315
|
-
return console.log(`Please add some elements in the option "autoelements"`);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
assignAutoClass(section, options.autoelements, 'global');
|
|
319
|
-
}
|
|
320
|
-
} else if (sectDataAppear.length > 0) {
|
|
321
|
-
// This section should get the local data-autoappear classes on its objects
|
|
322
|
-
assignAutoClass(section, sectDataAppear, 'local'); //section.removeAttribute("data-autoappear");
|
|
323
|
-
}
|
|
324
|
-
} else {
|
|
325
|
-
if (options.autoappear) {
|
|
326
|
-
if (!options.autoelements) {
|
|
327
|
-
return console.log(`Please add some elements in the option "autoelements"`);
|
|
328
|
-
} // This section should get the global autoappear classes on its objects
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
assignAutoClass(section, options.autoelements, 'global');
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
if (options.compatibility) {
|
|
338
|
-
animatecss = '.backInDown, .backInLeft, .backInRight, .backInUp, .bounceIn, .bounceInDown, .bounceInLeft, .bounceInRight, .bounceInUp, .fadeIn, .fadeInDown, .fadeInDownBig, .fadeInLeft, .fadeInLeftBig, .fadeInRight, .fadeInRightBig, .fadeInUp, .fadeInUpBig, .fadeInTopLeft, .fadeInTopRight, .fadeInBottomLeft, .fadeInBottomRight, .flipInX, .flipInY, .lightSpeedInRight, .lightSpeedInLeft, .rotateIn, .rotateInDownLeft, .rotateInDownRight, .rotateInUpLeft, .rotateInUpRight, .jackInTheBox, .rollIn, .zoomIn, .zoomInDown, .zoomInLeft, .zoomInRight, .zoomInUp, .slideInDown, .slideInLeft, .slideInRight, .slideInUp, .skidLeft, .skidLeftBig, .skidRight, .skidRightBig, .shrinkIn, .shrinkInBlur';
|
|
339
|
-
baseclass = options.compatibilitybaseclass;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
let allappearances = deck.getRevealElement().querySelectorAll(animatecss);
|
|
343
|
-
allappearances.forEach(appearance => {
|
|
344
|
-
if (!appearance.classList.contains(baseclass)) {
|
|
345
|
-
appearance.classList.add(baseclass);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
autoAdd();
|
|
349
|
-
sections.forEach(section => {
|
|
350
|
-
findAppearancesIn(section, appearanceSelector, fragmentSelector);
|
|
351
|
-
});
|
|
352
|
-
fragments.forEach(fragment => {
|
|
353
|
-
findAppearancesIn(fragment, appearanceSelector, fragmentSelector);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
const fromTo = function (event) {
|
|
357
|
-
let slides = {};
|
|
358
|
-
slides.from = event.fromSlide ? event.fromSlide : event.previousSlide ? event.previousSlide : null;
|
|
359
|
-
slides.to = event.toSlide ? event.toSlide : event.currentSlide ? event.currentSlide : null;
|
|
360
|
-
return slides;
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const showHideSlide = function (event) {
|
|
364
|
-
var _slides$to;
|
|
365
|
-
|
|
366
|
-
let etype = event.type;
|
|
367
|
-
let slides = fromTo(event);
|
|
368
|
-
debugLog(etype);
|
|
369
|
-
|
|
370
|
-
if (((_slides$to = slides.to) === null || _slides$to === void 0 ? void 0 : _slides$to.dataset.appearevent) == "auto") {
|
|
371
|
-
slides.to.dataset.appearevent = "autoanimate";
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (options.appearevent == "auto") {
|
|
375
|
-
options.appearevent = "autoanimate";
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (etype == "ready") {
|
|
379
|
-
slides.to.dataset.appearanceCanStart = true;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (slides.to) {
|
|
383
|
-
let appearevent = slides.to.dataset.appearevent ? slides.to.dataset.appearevent : options.appearevent;
|
|
384
|
-
|
|
385
|
-
if (etype == appearevent || etype == "slidetransitionend" && appearevent == "autoanimate") {
|
|
386
|
-
slides.to.dataset.appearanceCanStart = true;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (etype == "slidetransitionend") {
|
|
390
|
-
if (options.hideagain) {
|
|
391
|
-
if (slides.from) {
|
|
392
|
-
if (slides.from.dataset.appearanceCanStart) {
|
|
393
|
-
delete slides.from.dataset.appearanceCanStart;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
let fromFragments = slides.from.querySelectorAll(`.fragment.visible`);
|
|
397
|
-
|
|
398
|
-
if (fromFragments) {
|
|
399
|
-
fromFragments.forEach(fragment => {
|
|
400
|
-
fragment.classList.remove('visible');
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (event.type == 'slidechanged' && document.body.dataset.exitoverview) {
|
|
408
|
-
if (options.hideagain) {
|
|
409
|
-
var _slides$from;
|
|
410
|
-
|
|
411
|
-
(_slides$from = slides.from) === null || _slides$from === void 0 ? true : delete _slides$from.dataset.appearanceCanStart;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
slides.to.dataset.appearanceCanStart = true;
|
|
415
|
-
} else if (event.type == 'overviewhidden') {
|
|
416
|
-
document.body.dataset.exitoverview = true;
|
|
417
|
-
setTimeout(function () {
|
|
418
|
-
document.body.removeAttribute('data-exitoverview');
|
|
419
|
-
}, 500);
|
|
420
|
-
|
|
421
|
-
if (event.currentSlide) {
|
|
422
|
-
if (options.hideagain) {
|
|
423
|
-
var _slides$from2;
|
|
424
|
-
|
|
425
|
-
(_slides$from2 = slides.from) === null || _slides$from2 === void 0 ? true : delete _slides$from2.dataset.appearanceCanStart;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
slides.to.dataset.appearanceCanStart = true;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
const eventnames = ['ready', 'slidechanged', 'slidetransitionend', 'autoanimate', 'overviewhidden'];
|
|
435
|
-
eventnames.forEach(eventname => deck.on(eventname, event => {
|
|
436
|
-
showHideSlide(event);
|
|
437
|
-
}));
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const init = function (deck) {
|
|
441
|
-
let es5Filename = "appearance.js";
|
|
442
|
-
let defaultOptions = {
|
|
443
|
-
baseclass: 'animate__animated',
|
|
444
|
-
hideagain: true,
|
|
445
|
-
delay: 300,
|
|
446
|
-
debug: false,
|
|
447
|
-
appearevent: 'slidetransitionend',
|
|
448
|
-
autoappear: false,
|
|
449
|
-
autoelements: false,
|
|
450
|
-
appearparents: false,
|
|
451
|
-
csspath: '',
|
|
452
|
-
animatecsspath: {
|
|
453
|
-
link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css',
|
|
454
|
-
compat: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css'
|
|
455
|
-
},
|
|
456
|
-
compatibility: false,
|
|
457
|
-
compatibilitybaseclass: 'animated'
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
const defaults = function (options, defaultOptions) {
|
|
461
|
-
for (let i in defaultOptions) {
|
|
462
|
-
if (!options.hasOwnProperty(i)) {
|
|
463
|
-
options[i] = defaultOptions[i];
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
let options = deck.getConfig().appearance || {};
|
|
469
|
-
defaults(options, defaultOptions);
|
|
470
|
-
|
|
471
|
-
function pluginPath() {
|
|
472
|
-
let path;
|
|
473
|
-
let pluginScript = document.querySelector(`script[src$="${es5Filename}"]`);
|
|
474
|
-
|
|
475
|
-
if (pluginScript) {
|
|
476
|
-
path = pluginScript.getAttribute("src").slice(0, -1 * es5Filename.length);
|
|
477
|
-
} else {
|
|
478
|
-
path = (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('appearance.js', document.baseURI).href)).slice(0, (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('appearance.js', document.baseURI).href)).lastIndexOf('/') + 1);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return path;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
let AppearanceStylePath = options.csspath.appearance ? options.csspath.appearance : `${pluginPath()}appearance.css` || 'plugin/appearance/appearance.css';
|
|
485
|
-
let AnimateCSSPath = !options.compatibility ? options.animatecsspath.link : options.animatecsspath.compat;
|
|
486
|
-
|
|
487
|
-
if (options.debug) {
|
|
488
|
-
console.log(`Plugin path = ${pluginPath()}`);
|
|
489
|
-
console.log(`Compatibility mode: ${options.compatibility}`);
|
|
490
|
-
console.log(`Appearance CSS path = ${AppearanceStylePath}`);
|
|
491
|
-
console.log(`AnimateCSS CSS path = ${AnimateCSSPath}`);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
loadStyle(AnimateCSSPath, 'stylesheet', function () {
|
|
495
|
-
loadStyle(AppearanceStylePath, 'stylesheet');
|
|
496
|
-
});
|
|
497
|
-
appear(deck, options);
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
return {
|
|
501
|
-
id: 'appearance',
|
|
502
|
-
init: init
|
|
503
|
-
};
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
return Plugin;
|
|
507
|
-
|
|
508
|
-
}));
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Appearance=t()}(this,(function(){"use strict";var e="undefined"!=typeof document?document.currentScript:null;const t=e=>e&&"object"==typeof e&&!Array.isArray(e),a=(e,...n)=>{if(!n.length)return e;const s=n.shift();if(t(e)&&t(s))for(const n in s)t(s[n])?(e[n]||Object.assign(e,{[n]:{}}),a(e[n],s[n])):Object.assign(e,{[n]:s[n]});return a(e,...n)},n=e=>{let t="";return"string"==typeof e&&(e=e.replace(/[“”]/g,'"').replace(/[‘’]/g,"'")),t=(e=>{try{return JSON.parse(e)&&!!e}catch(e){return!1}})(e)?e:"object"==typeof e?JSON.stringify(e,null,2):"{"===e.trim().replace(/'/g,'"').charAt(0)?e.trim().replace(/'/g,'"'):`{${e.trim().replace(/'/g,'"')}}`,t},s=(e,t,a)=>{let n,s=document.querySelector("head");"script"===t?(n=document.createElement("script"),n.type="text/javascript",n.src=e):"stylesheet"===t&&(n=document.createElement("link"),n.rel="stylesheet",n.href=e);const r=()=>{"function"==typeof a&&(a.call(),a=null)};n.onload=r,n.onreadystatechange=function(){"loaded"===this.readyState&&r()},s.appendChild(n)},r=(e,t)=>{e.debug&&console.log(t)},i=(t,a)=>{let n=(t=>{let a,n=document.querySelector(`script[src$="${t}"]`);return a=n?n.getAttribute("src").slice(0,-1*t.length):("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("appearance.js",document.baseURI).href).slice(0,("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("appearance.js",document.baseURI).href).lastIndexOf("/")+1),a})(a),r=a.replace(/\.[^/.]+$/,""),i=t.csspath.appearance?t.csspath.appearance:`${n}${r}.css`||`plugin/${r}/${r}.css`,o=t.compatibility?t.animatecsspath.compat:t.animatecsspath.link;t.debug&&(console.log("Paths:"),console.log(` - Plugin path = ${n}`),console.log(` - Appearance CSS path = ${i}`),console.log(` - AnimateCSS CSS path = ${o}`)),s(o,"stylesheet",(function(){s(i,"stylesheet")}))},o=(e,t)=>{let a=e.parentNode;if(a){for(const t of a.children)if(t!==e&&t.dataset.appearParent)return;a.classList=e.classList,(({attributes:e},t,a)=>{[...e].filter((({nodeName:e})=>e.includes("data"))).forEach((({nodeName:e,nodeValue:n})=>{(a&&e!==a||!a)&&t.setAttribute(e,n)}))})(e,a,"data-appear-parent"),a.innerHTML=e.innerHTML,a.classList.add(t)}},l=(e,t,a)=>Array.from(a.querySelectorAll(`.${e}`)).filter((e=>!e.closest(`.${t}`))),c=(e,t,a)=>{const n=[l(t,a,e),...Array.from(e.querySelectorAll(`.${a}`)).map((e=>((e,t,a)=>Array.from(a.querySelectorAll(`.${e}`)).filter((e=>e.closest(`.${t}`)===a)))(t,a,e)))];return!!n.some((e=>e.length>0))&&n},d=(e,t)=>{t.hideagain&&e.from&&e.from.dataset.appearanceCanStart&&e.from.removeAttribute("data-appearance-can-start")},p=(e,t,a)=>{if(t.hideagain){e.from.querySelectorAll(a.animatecss).forEach((e=>{e.classList.remove("animationended")}));let t=e.from.querySelectorAll(".fragment.visible");t&&t.forEach((e=>{e.classList.remove("visible")}))}};return()=>{const e={names:{}};let t={};const s=(e,t,a)=>{r(e,"------------- Preloading -------------");let s=t.names;i(e,s.es5Filename),e.compatibility&&(s.animatecss=".backInDown, .backInLeft, .backInRight, .backInUp, .bounceIn, .bounceInDown, .bounceInLeft, .bounceInRight, .bounceInUp, .fadeIn, .fadeInDown, .fadeInDownBig, .fadeInLeft, .fadeInLeftBig, .fadeInRight, .fadeInRightBig, .fadeInUp, .fadeInUpBig, .fadeInTopLeft, .fadeInTopRight, .fadeInBottomLeft, .fadeInBottomRight, .flipInX, .flipInY, .lightSpeedInRight, .lightSpeedInLeft, .rotateIn, .rotateInDownLeft, .rotateInDownRight, .rotateInUpLeft, .rotateInUpRight, .jackInTheBox, .rollIn, .zoomIn, .zoomInDown, .zoomInLeft, .zoomInRight, .zoomInUp, .slideInDown, .slideInLeft, .slideInRight, .slideInUp, .skidLeft, .skidLeftBig, .skidRight, .skidRightBig, .shrinkIn, .shrinkInBlur",s.baseclass=e.compatibilitybaseclass),t.appearances=Array.from(t.slides.querySelectorAll(s.animatecss)),t.regularSections.forEach((a=>((e,t,a)=>{let s=null;if(e.hasAttribute("data-autoappear")){let a=e.dataset.autoappear;s="auto"==a||""==a||a.length<1||"true"==a?t.autoelements?t.autoelements:null:a}else t.autoappear&&t.autoelements&&(s=t.autoelements);if(s){let t=JSON.parse(n(s));Object.entries(t).forEach((([t,n])=>{let s=Array.from(e.querySelectorAll(t)).filter((e=>!a.appearances.includes(e)));s.length&&s.forEach((e=>{a.appearances.push(e);let t=[],s=null,r=!1,i=null,o=null;Array.isArray(n)?(t=n[0].split(/[ ,]+/),s=n[1]):"string"==typeof n?t=n.split(/[ ,]+/):n.constructor===Object&&((n.class||n.animation)&&(t=(n.animation?n.animation:n.class).split(/[ ,]+/)),n.speed&&(r=String(n.speed),r.includes("animate__")||(r=`animate__${r}`)),n.delay&&(s=String(n.delay)),n.split&&(i=String(n.split)),n["container-delay"]&&(o=String(n["container-delay"]))),e.classList.add(...t),r&&e.classList.add(r),s&&(e.dataset.delay=s),i&&(e.dataset.split=i),o&&(e.dataset.containerDelay=o)}))}))}})(a,e,t))),t.appearances.forEach(((t,a)=>{((e,t,a)=>{let n=a.baseclass;e.hasAttribute("data-appear-parent")&&o(e,n),t.appearparents&&e.parentNode&&e.parentNode.tagName&&"SPAN"==e.tagName&&"LI"==e.parentNode.tagName&&String(e.outerHTML).length==String(e.parentNode.innerHTML).length&&o(e)})(t,e,s),((e,t)=>{e.classList.contains(t.baseclass)||e.classList.add(t.baseclass),e.classList.contains(t.fragmentClass)&&e.classList.add("custom")})(t,s),t.hasAttribute("data-split")&&((e,t)=>{let a=!1,n=" ";if("words"==t?a=e.textContent.trim().split(/\s+/):"letters"==t&&(a=e.textContent.trim().split(""),n=""),a){const t=Array.from(e.classList).filter((e=>e.startsWith("animate__"))),s=a.map(((t,a)=>{const n=document.createElement("span");return n.textContent=t," "==t&&(n.textContent=" "),e.dataset.delay&&0!==a&&(n.dataset.delay=e.dataset.delay),e.dataset.containerDelay&&0===a&&(n.dataset.delay=e.dataset.containerDelay),e.classList.forEach((e=>e.startsWith("animate__")&&n.classList.add(e))),n.outerHTML})).join(n);t.forEach((t=>e.classList.remove(t))),e.removeAttribute("data-delay"),e.removeAttribute("data-split"),e.removeAttribute("data-container-delay"),e.innerHTML=s}})(t,t.dataset.split)})),t.regularSections.forEach(((t,a)=>{let n=c(t,s.baseclass,s.fragmentClass);n&&n.forEach((t=>{((e,t,a)=>{let n=0;e.forEach(((e,a)=>{if(0==a&&e.dataset.delay||0!=a){let a=t.delay;e.dataset&&e.dataset.delay&&(a=parseInt(e.dataset.delay)),n+=a,e.style.setProperty("animation-delay",n+"ms"),e.removeAttribute("data-delay")}}))})(t,e)}))})),(e=>{setTimeout(e,0)})(a)},l=function(t,a,n){let i=e.names;return i.baseclass=a.baseclass,i.compatibilitybaseclass=a.compatibilitybaseclass,i.fragmentSelector=".fragment",i.fragmentClass="fragment",i.speedClasses=["slower","slow","fast","faster"],i.speedClasses.push(...i.speedClasses.map((e=>`animate__${e}`))),i.animatecss='[class^="animate__"],[class*=" animate__"]',i.es5Filename=n,i.eventnames=["ready","slidechanged","slidetransitionend","autoanimate","overviewhidden","scrolle"],e.deck=t,e.dom=t.getRevealElement(),e.viewport=t.getViewportElement(),e.slides=t.getSlidesElement(),e.sections=e.slides.querySelectorAll("section"),e.fragments=e.slides.querySelectorAll(i.fragmentSelector),e.regularSections=Array.from(e.sections).filter((e=>!(({childNodes:e})=>{let t=!1;for(let a=0;a<e.length;a++)if("SECTION"==e[a].tagName){t=!0;break}return t})(e))),/receiver/i.test(window.location.search)&&e.viewport.classList.add("sv"),i.eventnames.forEach((n=>t.on(n,(t=>{((e,t,a,n)=>{let s=n.deck.getConfig().view,r=e.type,i=(e=>{let t={};return t.from=e.fromSlide||e.previousSlide||null,t.to=e.toSlide||e.currentSlide||null,t})(e);if(i.to){"ready"==r&&(i.to.dataset.appearanceCanStart=!0);let n=((e,t)=>(e.dataset.appearevent&&"auto"===e.dataset.appearevent&&(e.dataset.appearevent="autoanimate"),"auto"==t.appearevent&&(t.appearevent="autoanimate"),e.dataset.appearevent?e.dataset.appearevent:t.appearevent))(i.to,t);(r==n||"slidetransitionend"==r&&"autoanimate"==n)&&(i.to.dataset.appearanceCanStart=!0),"scroll"==s&&"slidechanged"==r&&(d(i,t),p(i,t,a),setTimeout((()=>{i.to.dataset.appearanceCanStart=!0}),t.delay)),"slidetransitionend"==r&&(d(i,t),p(i,t,a)),"slidechanged"==r&&document.body.dataset.exitoverview?(d(i,t),i.to.dataset.appearanceCanStart=!0):"overviewhidden"==r&&(document.body.dataset.exitoverview=!0,setTimeout((()=>{document.body.removeAttribute("data-exitoverview")}),500),e.currentSlide&&(d(i,t),i.to.dataset.appearanceCanStart=!0))}})(t,a,i,e)})))),e.viewport.addEventListener("animationend",(e=>{e.target.classList.add("animationended")})),e.viewport.addEventListener("fragmenthidden",(e=>{e.fragment.classList.remove("animationended"),e.fragment.querySelectorAll(".animationended").forEach((e=>{e.classList.remove("animationended")}))})),new Promise((t=>{s(a,e,t),r(a,"---------- Done preloading ----------")}))};return{id:"appearance",init:function(e){return t=a({baseclass:"animate__animated",hideagain:!0,delay:300,debug:!1,appearevent:"slidetransitionend",autoappear:!1,autoelements:!1,appearparents:!1,csspath:"",animatecsspath:{link:"https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css",compat:"https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css"},compatibility:!1,compatibilitybaseclass:"animated"},e.getConfig().appearance||{}),l(e,t,"appearance.js")}}}}));
|