reveal.js-appearance 1.1.3 → 1.2.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/CHANGELOG.md +11 -0
- package/LICENSE +1 -1
- package/README.md +139 -51
- package/css/demo.css +106 -4
- package/demo-markdown.html +62 -0
- package/demo.html +312 -92
- package/img/5.jpg +0 -0
- package/markdown.md +156 -0
- package/package.json +4 -2
- package/plugin/appearance/appearance.css +17 -1
- package/plugin/appearance/appearance.esm.js +251 -162
- package/plugin/appearance/appearance.js +479 -390
- package/plugin/appearance/plugin-src.js +218 -34
- package/screenshot.png +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* https://github.com/Martinomagnifico
|
|
5
5
|
*
|
|
6
6
|
* Appearance.js for Reveal.js
|
|
7
|
-
* Version 1.
|
|
7
|
+
* Version 1.2.0
|
|
8
8
|
*
|
|
9
9
|
* @license
|
|
10
10
|
* MIT licensed
|
|
@@ -15,397 +15,486 @@
|
|
|
15
15
|
******************************************************************/
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
(function (global, factory) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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());
|
|
22
23
|
})(this, (function () { 'use strict';
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
+
const assignAutoClass = (section, str, kind) => {
|
|
151
|
+
let index = [...section.parentElement.children].filter(s => s.tagName == "SECTION").indexOf(section) + 1;
|
|
152
|
+
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}`;
|
|
153
|
+
if (typeof str === "string") str = str.replace(/[“”]/g, '"').replace(/[‘’]/g, "'");
|
|
154
|
+
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, '"')}}`;
|
|
155
|
+
|
|
156
|
+
if (!isJSON(strJSON)) {
|
|
157
|
+
console.log(warning);
|
|
158
|
+
} else {
|
|
159
|
+
let elementsToAnimate = JSON.parse(strJSON);
|
|
160
|
+
|
|
161
|
+
for (const [element, assignables] of Object.entries(elementsToAnimate)) {
|
|
162
|
+
let elementsInSection = section.querySelectorAll(element);
|
|
163
|
+
elementsInSection.forEach(elementInSection => {
|
|
164
|
+
if (!elementInSection.classList.contains(baseclass) || elementInSection.dataset["autoappear"]) {
|
|
165
|
+
elementInSection.dataset["autoappear"] = true;
|
|
166
|
+
let newClasses = [],
|
|
167
|
+
newDelay = null,
|
|
168
|
+
speedClass = false;
|
|
169
|
+
|
|
170
|
+
if (Array.isArray(assignables)) {
|
|
171
|
+
newClasses = assignables[0].split(/[ ,]+/);
|
|
172
|
+
newDelay = assignables[1];
|
|
173
|
+
} else if (typeof assignables == "string") {
|
|
174
|
+
newClasses = assignables.split(/[ ,]+/);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
speedClasses.forEach(speed => {
|
|
178
|
+
if (elementInSection.classList.contains(speed)) {
|
|
179
|
+
speedClass = speed;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
let classesToRemove = [];
|
|
183
|
+
elementInSection.classList.forEach(currentClass => {
|
|
184
|
+
if (String(currentClass).includes("animate__")) {
|
|
185
|
+
classesToRemove.push(currentClass);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
classesToRemove.forEach(currentClass => {
|
|
189
|
+
elementInSection.classList.remove(currentClass);
|
|
190
|
+
});
|
|
191
|
+
newClasses.forEach(newClass => {
|
|
192
|
+
if (speedClasses.includes(newClass)) {
|
|
193
|
+
// There is a speed class from JSON to be assigned
|
|
194
|
+
if (speedClass) {
|
|
195
|
+
speedClass = newClass;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
newClasses.forEach(newClass => {
|
|
200
|
+
elementInSection.classList.add(newClass);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (speedClass) {
|
|
204
|
+
elementInSection.classList.add(speedClass);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (newDelay) {
|
|
208
|
+
elementInSection.dataset.delay = newDelay;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
elementInSection.classList.add(baseclass);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const findAppearancesIn = function (container, includeClass, excludeClass) {
|
|
219
|
+
if (!isStack(container)) {
|
|
220
|
+
let appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
221
|
+
appearances.forEach(appearance => {
|
|
222
|
+
let convertListItem = appearance => {
|
|
223
|
+
let from = appearance,
|
|
224
|
+
to = appearance.parentNode;
|
|
225
|
+
if (!to) return;
|
|
226
|
+
|
|
227
|
+
for (let sibling of to.children) {
|
|
228
|
+
if (sibling !== appearance) {
|
|
229
|
+
if (sibling.dataset.appearParent) return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
to.classList = from.classList;
|
|
234
|
+
copyDataAttributes(from, to, "data-appear-parent");
|
|
235
|
+
to.innerHTML = from.innerHTML;
|
|
236
|
+
}; // Conversion of list items with Appearance classes to the parent, needs manual attribute
|
|
237
|
+
// Relates to Quarto wrapping list content in a span.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
if (appearance.hasAttribute("data-appear-parent")) {
|
|
241
|
+
convertListItem(appearance);
|
|
242
|
+
} // Automatic conversion of list items which directly contain spans.
|
|
243
|
+
// Relates to Quarto wrapping list content in a span.
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
if (options.appearparents) {
|
|
247
|
+
if (appearance.parentNode && appearance.parentNode.tagName) {
|
|
248
|
+
if (appearance.tagName == "SPAN" && appearance.parentNode.tagName == "LI") {
|
|
249
|
+
let spanLength = String(appearance.outerHTML).length;
|
|
250
|
+
let liContentLength = String(appearance.parentNode.innerHTML).length;
|
|
251
|
+
|
|
252
|
+
if (spanLength == liContentLength) {
|
|
253
|
+
convertListItem(appearance);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
260
|
+
let excludes = selectionArray(container, `:scope ${excludeClass} ${includeClass}`);
|
|
261
|
+
let delay = 0;
|
|
262
|
+
appearances.filter(function (appearance, index) {
|
|
263
|
+
if (!(excludes.indexOf(appearance) > -1)) {
|
|
264
|
+
if (index == 0 && appearance.dataset.delay || index != 0) {
|
|
265
|
+
let elementDelay = options.delay;
|
|
266
|
+
|
|
267
|
+
if (appearance.dataset && appearance.dataset.delay) {
|
|
268
|
+
elementDelay = parseInt(appearance.dataset.delay);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
delay = delay + elementDelay; // Allow fragments to be Appearance items
|
|
272
|
+
|
|
273
|
+
if (appearance.classList.contains("fragment")) {
|
|
274
|
+
delay = 0;
|
|
275
|
+
|
|
276
|
+
if (appearance.querySelectorAll(`.${baseclass}`)) {
|
|
277
|
+
let firstNestedAppearance = appearance.querySelectorAll(`.${baseclass}`)[0];
|
|
278
|
+
|
|
279
|
+
if (firstNestedAppearance) {
|
|
280
|
+
let elementDelay = options.delay;
|
|
281
|
+
|
|
282
|
+
if (firstNestedAppearance.dataset && firstNestedAppearance.dataset.delay) {
|
|
283
|
+
elementDelay = parseInt(firstNestedAppearance.dataset.delay);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
firstNestedAppearance.dataset.delay = elementDelay;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
appearance.style.setProperty('animation-delay', delay + "ms");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const autoAdd = function () {
|
|
299
|
+
regularSections.forEach(section => {
|
|
300
|
+
if (section.hasAttribute("data-autoappear")) {
|
|
301
|
+
let sectDataAppear = section.dataset.autoappear;
|
|
302
|
+
|
|
303
|
+
if (sectDataAppear == "auto" || sectDataAppear == "" || sectDataAppear.length < 1 || sectDataAppear == "true") {
|
|
304
|
+
// This section should get the global autoappear classes on its objects
|
|
305
|
+
if (options.autoelements) {
|
|
306
|
+
if (!options.autoelements) {
|
|
307
|
+
return console.log(`Please add some elements in the option "autoelements"`);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
assignAutoClass(section, options.autoelements, 'global');
|
|
311
|
+
}
|
|
312
|
+
} else if (sectDataAppear.length > 0) {
|
|
313
|
+
// This section should get the local data-autoappear classes on its objects
|
|
314
|
+
assignAutoClass(section, sectDataAppear, 'local'); //section.removeAttribute("data-autoappear");
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
if (options.autoappear) {
|
|
318
|
+
if (!options.autoelements) {
|
|
319
|
+
return console.log(`Please add some elements in the option "autoelements"`);
|
|
320
|
+
} // This section should get the global autoappear classes on its objects
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
assignAutoClass(section, options.autoelements, 'global');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
if (options.compatibility) {
|
|
330
|
+
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';
|
|
331
|
+
baseclass = options.compatibilitybaseclass;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
let allappearances = deck.getRevealElement().querySelectorAll(animatecss);
|
|
335
|
+
allappearances.forEach(appearance => {
|
|
336
|
+
if (!appearance.classList.contains(baseclass)) {
|
|
337
|
+
appearance.classList.add(baseclass);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
autoAdd();
|
|
341
|
+
sections.forEach(section => {
|
|
342
|
+
findAppearancesIn(section, appearanceSelector, fragmentSelector);
|
|
343
|
+
});
|
|
344
|
+
fragments.forEach(fragment => {
|
|
345
|
+
findAppearancesIn(fragment, appearanceSelector, fragmentSelector);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const fromTo = function (event) {
|
|
349
|
+
let slides = {};
|
|
350
|
+
slides.from = event.fromSlide ? event.fromSlide : event.previousSlide ? event.previousSlide : null;
|
|
351
|
+
slides.to = event.toSlide ? event.toSlide : event.currentSlide ? event.currentSlide : null;
|
|
352
|
+
return slides;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const showHideSlide = function (event) {
|
|
356
|
+
var _slides$to;
|
|
357
|
+
|
|
358
|
+
let etype = event.type;
|
|
359
|
+
let slides = fromTo(event);
|
|
360
|
+
debugLog(etype);
|
|
361
|
+
|
|
362
|
+
if (((_slides$to = slides.to) === null || _slides$to === void 0 ? void 0 : _slides$to.dataset.appearevent) == "auto") {
|
|
363
|
+
slides.to.dataset.appearevent = "autoanimate";
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (options.appearevent == "auto") {
|
|
367
|
+
options.appearevent = "autoanimate";
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (etype == "ready") {
|
|
371
|
+
slides.to.dataset.appearanceCanStart = true;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (slides.to) {
|
|
375
|
+
let appearevent = slides.to.dataset.appearevent ? slides.to.dataset.appearevent : options.appearevent;
|
|
376
|
+
|
|
377
|
+
if (etype == appearevent || etype == "slidetransitionend" && appearevent == "autoanimate") {
|
|
378
|
+
slides.to.dataset.appearanceCanStart = true;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (etype == "slidetransitionend") {
|
|
382
|
+
if (options.hideagain) {
|
|
383
|
+
if (slides.from) {
|
|
384
|
+
if (slides.from.dataset.appearanceCanStart) {
|
|
385
|
+
delete slides.from.dataset.appearanceCanStart;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let fromFragments = slides.from.querySelectorAll(`.fragment.visible`);
|
|
389
|
+
|
|
390
|
+
if (fromFragments) {
|
|
391
|
+
fromFragments.forEach(fragment => {
|
|
392
|
+
fragment.classList.remove('visible');
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (event.type == 'slidechanged' && document.body.dataset.exitoverview) {
|
|
400
|
+
if (options.hideagain) {
|
|
401
|
+
var _slides$from;
|
|
402
|
+
|
|
403
|
+
(_slides$from = slides.from) === null || _slides$from === void 0 ? true : delete _slides$from.dataset.appearanceCanStart;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
slides.to.dataset.appearanceCanStart = true;
|
|
407
|
+
} else if (event.type == 'overviewhidden') {
|
|
408
|
+
document.body.dataset.exitoverview = true;
|
|
409
|
+
setTimeout(function () {
|
|
410
|
+
document.body.removeAttribute('data-exitoverview');
|
|
411
|
+
}, 500);
|
|
412
|
+
|
|
413
|
+
if (event.currentSlide) {
|
|
414
|
+
if (options.hideagain) {
|
|
415
|
+
var _slides$from2;
|
|
416
|
+
|
|
417
|
+
(_slides$from2 = slides.from) === null || _slides$from2 === void 0 ? true : delete _slides$from2.dataset.appearanceCanStart;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
slides.to.dataset.appearanceCanStart = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const eventnames = ['ready', 'slidechanged', 'slidetransitionend', 'autoanimate', 'overviewhidden'];
|
|
427
|
+
eventnames.forEach(eventname => deck.on(eventname, event => {
|
|
428
|
+
showHideSlide(event);
|
|
429
|
+
}));
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const init = function (deck) {
|
|
433
|
+
let es5Filename = "appearance.js";
|
|
434
|
+
let defaultOptions = {
|
|
435
|
+
baseclass: 'animate__animated',
|
|
436
|
+
hideagain: true,
|
|
437
|
+
delay: 300,
|
|
438
|
+
debug: false,
|
|
439
|
+
appearevent: 'slidetransitionend',
|
|
440
|
+
autoappear: false,
|
|
441
|
+
autoelements: false,
|
|
442
|
+
appearparents: false,
|
|
443
|
+
csspath: '',
|
|
444
|
+
animatecsspath: {
|
|
445
|
+
link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css',
|
|
446
|
+
compat: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css'
|
|
447
|
+
},
|
|
448
|
+
compatibility: false,
|
|
449
|
+
compatibilitybaseclass: 'animated'
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const defaults = function (options, defaultOptions) {
|
|
453
|
+
for (let i in defaultOptions) {
|
|
454
|
+
if (!options.hasOwnProperty(i)) {
|
|
455
|
+
options[i] = defaultOptions[i];
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
let options = deck.getConfig().appearance || {};
|
|
461
|
+
defaults(options, defaultOptions);
|
|
462
|
+
|
|
463
|
+
function pluginPath() {
|
|
464
|
+
let path;
|
|
465
|
+
let pluginScript = document.querySelector(`script[src$="${es5Filename}"]`);
|
|
466
|
+
|
|
467
|
+
if (pluginScript) {
|
|
468
|
+
path = pluginScript.getAttribute("src").slice(0, -1 * es5Filename.length);
|
|
469
|
+
} else {
|
|
470
|
+
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);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return path;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
let AppearanceStylePath = options.csspath.appearance ? options.csspath.appearance : `${pluginPath()}appearance.css` || 'plugin/appearance/appearance.css';
|
|
477
|
+
let AnimateCSSPath = !options.compatibility ? options.animatecsspath.link : options.animatecsspath.compat;
|
|
478
|
+
|
|
479
|
+
if (options.debug) {
|
|
480
|
+
console.log(`Plugin path = ${pluginPath()}`);
|
|
481
|
+
console.log(`Compatibility mode: ${options.compatibility}`);
|
|
482
|
+
console.log(`Appearance CSS path = ${AppearanceStylePath}`);
|
|
483
|
+
console.log(`AnimateCSS CSS path = ${AnimateCSSPath}`);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
loadStyle(AnimateCSSPath, 'stylesheet', function () {
|
|
487
|
+
loadStyle(AppearanceStylePath, 'stylesheet');
|
|
488
|
+
});
|
|
489
|
+
appear(deck, options);
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
return {
|
|
493
|
+
id: 'appearance',
|
|
494
|
+
init: init
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
return Plugin;
|
|
410
499
|
|
|
411
500
|
}));
|