reveal.js-appearance 1.1.2 → 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 +16 -0
- package/LICENSE +1 -1
- package/README.md +140 -52
- 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 +5 -3
- package/plugin/appearance/appearance.css +17 -1
- package/plugin/appearance/appearance.esm.js +265 -170
- package/plugin/appearance/appearance.js +479 -384
- package/plugin/appearance/plugin-src.js +229 -39
- package/screenshot.png +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reveal.js-appearance",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"main": "plugin/appearance/appearance.js",
|
|
5
|
+
"module": "plugin/appearance/appearance.esm.js",
|
|
6
|
+
"description": "An animation plugin for Reveal.js that animates elements sequentially like in Powerpoint. Perfect for online portfolios or other presentations with images.",
|
|
5
7
|
"keywords": "reveal, reveal.js, reveal-plugin, plugin, text effects, powerpoint",
|
|
6
8
|
"homepage": "https://github.com/Martinomagnifico/reveal.js-appearance",
|
|
7
9
|
"repository": {
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
"url": "https://github.com/Martinomagnifico/reveal.js-appearance.git"
|
|
10
12
|
},
|
|
11
13
|
"author": "Martijn De Jongh",
|
|
12
|
-
"license": "MIT, Copyright (C)
|
|
14
|
+
"license": "MIT, Copyright (C) 2023 Martijn De Jongh",
|
|
13
15
|
"peerDependencies": {
|
|
14
16
|
"reveal.js": "^4.2"
|
|
15
17
|
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
****************************************************************
|
|
3
|
+
* @author: Martijn De Jongh (Martino), martijn.de.jongh@gmail.com
|
|
4
|
+
* https://github.com/Martinomagnifico
|
|
5
|
+
*
|
|
6
|
+
* Appearance.js for Reveal.js
|
|
7
|
+
* Version 1.2.0
|
|
8
|
+
*
|
|
9
|
+
* @license
|
|
10
|
+
* MIT licensed
|
|
11
|
+
*
|
|
12
|
+
* Thanks to:
|
|
13
|
+
* - Hakim El Hattab, Reveal.js
|
|
14
|
+
* - Daniel Eden, Animate.css
|
|
15
|
+
*****************************************************************
|
|
16
|
+
*/
|
|
1
17
|
/* Animate.css overrides */
|
|
2
18
|
section:not(.stack):not([data-appearance-can-start]) .animate__animated, section:not(.stack):not([data-appearance-can-start]) .animated {
|
|
3
19
|
opacity: 0;
|
|
@@ -11,7 +27,7 @@ section:not(.stack):not([data-appearance-can-start]) .animate__animated, section
|
|
|
11
27
|
opacity: 1;
|
|
12
28
|
}
|
|
13
29
|
|
|
14
|
-
.fragment:not(.visible) .animate__animated, .fragment:not(.visible) .animated {
|
|
30
|
+
.fragment:not(.visible) .animate__animated, .fragment:not(.visible) .animated, .fragment:not(.visible).animate__animated, .fragment:not(.visible).animated {
|
|
15
31
|
opacity: 0;
|
|
16
32
|
-webkit-animation: none;
|
|
17
33
|
animation: none;
|
|
@@ -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,84 +15,26 @@
|
|
|
15
15
|
******************************************************************/
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
function _slicedToArray(arr, i) {
|
|
19
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
20
|
-
}
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
if (Array.isArray(arr)) return arr;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _iterableToArrayLimit(arr, i) {
|
|
27
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
28
|
-
|
|
29
|
-
if (_i == null) return;
|
|
30
|
-
var _arr = [];
|
|
31
|
-
var _n = true;
|
|
32
|
-
var _d = false;
|
|
33
|
-
|
|
34
|
-
var _s, _e;
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
38
|
-
_arr.push(_s.value);
|
|
39
|
-
|
|
40
|
-
if (i && _arr.length === i) break;
|
|
41
|
-
}
|
|
42
|
-
} catch (err) {
|
|
43
|
-
_d = true;
|
|
44
|
-
_e = err;
|
|
45
|
-
} finally {
|
|
46
|
-
try {
|
|
47
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
48
|
-
} finally {
|
|
49
|
-
if (_d) throw _e;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return _arr;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
57
|
-
if (!o) return;
|
|
58
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
59
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
60
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
61
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
62
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function _arrayLikeToArray(arr, len) {
|
|
66
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
67
|
-
|
|
68
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
69
|
-
|
|
70
|
-
return arr2;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function _nonIterableRest() {
|
|
74
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var Plugin = function Plugin() {
|
|
19
|
+
const Plugin = () => {
|
|
78
20
|
// Scope support polyfill
|
|
79
21
|
try {
|
|
80
22
|
document.querySelector(":scope *");
|
|
81
23
|
} catch (t) {
|
|
82
24
|
!function (t) {
|
|
83
|
-
|
|
25
|
+
let e = /:scope(?![\w-])/gi,
|
|
84
26
|
r = u(t.querySelector);
|
|
85
27
|
|
|
86
28
|
t.querySelector = function (t) {
|
|
87
29
|
return r.apply(this, arguments);
|
|
88
30
|
};
|
|
89
31
|
|
|
90
|
-
|
|
32
|
+
let c = u(t.querySelectorAll);
|
|
91
33
|
|
|
92
34
|
if (t.querySelectorAll = function (t) {
|
|
93
35
|
return c.apply(this, arguments);
|
|
94
36
|
}, t.matches) {
|
|
95
|
-
|
|
37
|
+
let n = u(t.matches);
|
|
96
38
|
|
|
97
39
|
t.matches = function (t) {
|
|
98
40
|
return n.apply(this, arguments);
|
|
@@ -100,7 +42,7 @@ var Plugin = function Plugin() {
|
|
|
100
42
|
}
|
|
101
43
|
|
|
102
44
|
if (t.closest) {
|
|
103
|
-
|
|
45
|
+
let o = u(t.closest);
|
|
104
46
|
|
|
105
47
|
t.closest = function (t) {
|
|
106
48
|
return o.apply(this, arguments);
|
|
@@ -110,13 +52,10 @@ var Plugin = function Plugin() {
|
|
|
110
52
|
function u(t) {
|
|
111
53
|
return function (r) {
|
|
112
54
|
if (r && e.test(r)) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var _n = t.apply(this, arguments);
|
|
118
|
-
|
|
119
|
-
return this.removeAttribute(_c), _n;
|
|
55
|
+
let c = "q" + Math.floor(9e6 * Math.random()) + 1e6;
|
|
56
|
+
arguments[0] = r.replace(e, "[" + c + "]"), this.setAttribute(c, "");
|
|
57
|
+
let n = t.apply(this, arguments);
|
|
58
|
+
return this.removeAttribute(c), n;
|
|
120
59
|
}
|
|
121
60
|
|
|
122
61
|
return t.apply(this, arguments);
|
|
@@ -125,14 +64,14 @@ var Plugin = function Plugin() {
|
|
|
125
64
|
}(Element.prototype);
|
|
126
65
|
}
|
|
127
66
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
67
|
+
const loadStyle = function (url, type, callback) {
|
|
68
|
+
let head = document.querySelector('head');
|
|
69
|
+
let style;
|
|
131
70
|
style = document.createElement('link');
|
|
132
71
|
style.rel = 'stylesheet';
|
|
133
72
|
style.href = url;
|
|
134
73
|
|
|
135
|
-
|
|
74
|
+
let finish = function () {
|
|
136
75
|
if (typeof callback === 'function') {
|
|
137
76
|
callback.call();
|
|
138
77
|
callback = null;
|
|
@@ -150,34 +89,199 @@ var Plugin = function Plugin() {
|
|
|
150
89
|
head.appendChild(style);
|
|
151
90
|
};
|
|
152
91
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
92
|
+
const isJSON = str => {
|
|
93
|
+
try {
|
|
94
|
+
return JSON.parse(str) && !!str;
|
|
95
|
+
} catch (e) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const selectionArray = function (container, selectors) {
|
|
101
|
+
let selections = container.querySelectorAll(selectors);
|
|
102
|
+
let selectionarray = Array.prototype.slice.call(selections);
|
|
156
103
|
return selectionarray;
|
|
157
104
|
};
|
|
158
105
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var appearanceSelector = options.compatibility ? ".".concat(options.compatibilitybaseclass) : ".".concat(baseclass);
|
|
162
|
-
var fragmentSelector = ".fragment";
|
|
163
|
-
var sections = deck.getRevealElement().querySelectorAll(".slides section");
|
|
164
|
-
var fragments = deck.getRevealElement().querySelectorAll(fragmentSelector);
|
|
165
|
-
var animatecss = '[class^="animate__"],[class*=" animate__"]';
|
|
106
|
+
const isStack = function (section) {
|
|
107
|
+
let isStack = false;
|
|
166
108
|
|
|
167
|
-
|
|
109
|
+
for (let i = 0; i < section.childNodes.length; i++) {
|
|
110
|
+
if (section.childNodes[i].tagName == "SECTION") {
|
|
111
|
+
isStack = true;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return isStack;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
function copyDataAttributes(source, target, not) {
|
|
120
|
+
[...source.attributes].filter(attr => attr.nodeName.indexOf('data') > -1).forEach(attr => {
|
|
121
|
+
if (not && attr.nodeName !== not || !not) {
|
|
122
|
+
target.setAttribute(attr.nodeName, attr.nodeValue);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const appear = function (deck, options) {
|
|
128
|
+
let baseclass = 'animate__animated';
|
|
129
|
+
let viewport = deck.getRevealElement().tagName == "BODY" ? document : deck.getRevealElement();
|
|
130
|
+
let appearanceSelector = options.compatibility ? `.${options.compatibilitybaseclass}` : `.${baseclass}`;
|
|
131
|
+
let fragmentSelector = ".fragment";
|
|
132
|
+
let speedClasses = ['slower', 'slow', 'fast', 'faster'];
|
|
133
|
+
speedClasses.push(...speedClasses.map(speed => `animate__${speed}`));
|
|
134
|
+
document.querySelector('[name=generator]');
|
|
135
|
+
const sections = selectionArray(viewport, "section");
|
|
136
|
+
const regularSections = sections.filter(section => !isStack(section) && section.dataset.visibility != "hidden");
|
|
137
|
+
const fragments = deck.getRevealElement().querySelectorAll(fragmentSelector);
|
|
138
|
+
let animatecss = '[class^="animate__"],[class*=" animate__"]';
|
|
139
|
+
|
|
140
|
+
const debugLog = function (text) {
|
|
168
141
|
if (options.debug) console.log(text);
|
|
169
142
|
};
|
|
170
143
|
|
|
171
|
-
|
|
144
|
+
const assignAutoClass = (section, str, kind) => {
|
|
145
|
+
let index = [...section.parentElement.children].filter(s => s.tagName == "SECTION").indexOf(section) + 1;
|
|
146
|
+
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}`;
|
|
147
|
+
if (typeof str === "string") str = str.replace(/[“”]/g, '"').replace(/[‘’]/g, "'");
|
|
148
|
+
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, '"')}}`;
|
|
149
|
+
|
|
150
|
+
if (!isJSON(strJSON)) {
|
|
151
|
+
console.log(warning);
|
|
152
|
+
} else {
|
|
153
|
+
let elementsToAnimate = JSON.parse(strJSON);
|
|
154
|
+
|
|
155
|
+
for (const [element, assignables] of Object.entries(elementsToAnimate)) {
|
|
156
|
+
let elementsInSection = section.querySelectorAll(element);
|
|
157
|
+
elementsInSection.forEach(elementInSection => {
|
|
158
|
+
if (!elementInSection.classList.contains(baseclass) || elementInSection.dataset["autoappear"]) {
|
|
159
|
+
elementInSection.dataset["autoappear"] = true;
|
|
160
|
+
let newClasses = [],
|
|
161
|
+
newDelay = null,
|
|
162
|
+
speedClass = false;
|
|
163
|
+
|
|
164
|
+
if (Array.isArray(assignables)) {
|
|
165
|
+
newClasses = assignables[0].split(/[ ,]+/);
|
|
166
|
+
newDelay = assignables[1];
|
|
167
|
+
} else if (typeof assignables == "string") {
|
|
168
|
+
newClasses = assignables.split(/[ ,]+/);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
speedClasses.forEach(speed => {
|
|
172
|
+
if (elementInSection.classList.contains(speed)) {
|
|
173
|
+
speedClass = speed;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
let classesToRemove = [];
|
|
177
|
+
elementInSection.classList.forEach(currentClass => {
|
|
178
|
+
if (String(currentClass).includes("animate__")) {
|
|
179
|
+
classesToRemove.push(currentClass);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
classesToRemove.forEach(currentClass => {
|
|
183
|
+
elementInSection.classList.remove(currentClass);
|
|
184
|
+
});
|
|
185
|
+
newClasses.forEach(newClass => {
|
|
186
|
+
if (speedClasses.includes(newClass)) {
|
|
187
|
+
// There is a speed class from JSON to be assigned
|
|
188
|
+
if (speedClass) {
|
|
189
|
+
speedClass = newClass;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
newClasses.forEach(newClass => {
|
|
194
|
+
elementInSection.classList.add(newClass);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (speedClass) {
|
|
198
|
+
elementInSection.classList.add(speedClass);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (newDelay) {
|
|
202
|
+
elementInSection.dataset.delay = newDelay;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
elementInSection.classList.add(baseclass);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const findAppearancesIn = function (container, includeClass, excludeClass) {
|
|
172
213
|
if (!isStack(container)) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
214
|
+
let appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
215
|
+
appearances.forEach(appearance => {
|
|
216
|
+
let convertListItem = appearance => {
|
|
217
|
+
let from = appearance,
|
|
218
|
+
to = appearance.parentNode;
|
|
219
|
+
if (!to) return;
|
|
220
|
+
|
|
221
|
+
for (let sibling of to.children) {
|
|
222
|
+
if (sibling !== appearance) {
|
|
223
|
+
if (sibling.dataset.appearParent) return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
to.classList = from.classList;
|
|
228
|
+
copyDataAttributes(from, to, "data-appear-parent");
|
|
229
|
+
to.innerHTML = from.innerHTML;
|
|
230
|
+
}; // Conversion of list items with Appearance classes to the parent, needs manual attribute
|
|
231
|
+
// Relates to Quarto wrapping list content in a span.
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if (appearance.hasAttribute("data-appear-parent")) {
|
|
235
|
+
convertListItem(appearance);
|
|
236
|
+
} // Automatic conversion of list items which directly contain spans.
|
|
237
|
+
// Relates to Quarto wrapping list content in a span.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
if (options.appearparents) {
|
|
241
|
+
if (appearance.parentNode && appearance.parentNode.tagName) {
|
|
242
|
+
if (appearance.tagName == "SPAN" && appearance.parentNode.tagName == "LI") {
|
|
243
|
+
let spanLength = String(appearance.outerHTML).length;
|
|
244
|
+
let liContentLength = String(appearance.parentNode.innerHTML).length;
|
|
245
|
+
|
|
246
|
+
if (spanLength == liContentLength) {
|
|
247
|
+
convertListItem(appearance);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
appearances = selectionArray(container, `:scope ${includeClass}`);
|
|
254
|
+
let excludes = selectionArray(container, `:scope ${excludeClass} ${includeClass}`);
|
|
255
|
+
let delay = 0;
|
|
176
256
|
appearances.filter(function (appearance, index) {
|
|
177
257
|
if (!(excludes.indexOf(appearance) > -1)) {
|
|
178
258
|
if (index == 0 && appearance.dataset.delay || index != 0) {
|
|
179
|
-
|
|
180
|
-
|
|
259
|
+
let elementDelay = options.delay;
|
|
260
|
+
|
|
261
|
+
if (appearance.dataset && appearance.dataset.delay) {
|
|
262
|
+
elementDelay = parseInt(appearance.dataset.delay);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
delay = delay + elementDelay; // Allow fragments to be Appearance items
|
|
266
|
+
|
|
267
|
+
if (appearance.classList.contains("fragment")) {
|
|
268
|
+
delay = 0;
|
|
269
|
+
|
|
270
|
+
if (appearance.querySelectorAll(`.${baseclass}`)) {
|
|
271
|
+
let firstNestedAppearance = appearance.querySelectorAll(`.${baseclass}`)[0];
|
|
272
|
+
|
|
273
|
+
if (firstNestedAppearance) {
|
|
274
|
+
let elementDelay = options.delay;
|
|
275
|
+
|
|
276
|
+
if (firstNestedAppearance.dataset && firstNestedAppearance.dataset.delay) {
|
|
277
|
+
elementDelay = parseInt(firstNestedAppearance.dataset.delay);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
firstNestedAppearance.dataset.delay = elementDelay;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
181
285
|
appearance.style.setProperty('animation-delay', delay + "ms");
|
|
182
286
|
}
|
|
183
287
|
}
|
|
@@ -185,49 +289,35 @@ var Plugin = function Plugin() {
|
|
|
185
289
|
}
|
|
186
290
|
};
|
|
187
291
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
autoelement = _Object$entries$_i[0],
|
|
193
|
-
autoanimation = _Object$entries$_i[1];
|
|
194
|
-
|
|
195
|
-
if (options.autoappear) {
|
|
196
|
-
debugLog("All \"".concat(autoelement, "\"\" elements will animate with ").concat(autoanimation));
|
|
197
|
-
}
|
|
292
|
+
const autoAdd = function () {
|
|
293
|
+
regularSections.forEach(section => {
|
|
294
|
+
if (section.hasAttribute("data-autoappear")) {
|
|
295
|
+
let sectDataAppear = section.dataset.autoappear;
|
|
198
296
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (!autoAppearance.classList.contains(baseclass)) {
|
|
205
|
-
autoAppearance.classList.add(baseclass);
|
|
206
|
-
autoAppearance.classList.add(autoanimation);
|
|
297
|
+
if (sectDataAppear == "auto" || sectDataAppear == "" || sectDataAppear.length < 1 || sectDataAppear == "true") {
|
|
298
|
+
// This section should get the global autoappear classes on its objects
|
|
299
|
+
if (options.autoelements) {
|
|
300
|
+
if (!options.autoelements) {
|
|
301
|
+
return console.log(`Please add some elements in the option "autoelements"`);
|
|
207
302
|
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
303
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
304
|
+
assignAutoClass(section, options.autoelements, 'global');
|
|
305
|
+
}
|
|
306
|
+
} else if (sectDataAppear.length > 0) {
|
|
307
|
+
// This section should get the local data-autoappear classes on its objects
|
|
308
|
+
assignAutoClass(section, sectDataAppear, 'local'); //section.removeAttribute("data-autoappear");
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
if (options.autoappear) {
|
|
312
|
+
if (!options.autoelements) {
|
|
313
|
+
return console.log(`Please add some elements in the option "autoelements"`);
|
|
314
|
+
} // This section should get the global autoappear classes on its objects
|
|
219
315
|
|
|
220
|
-
var isStack = function isStack(section) {
|
|
221
|
-
var isStack = false;
|
|
222
316
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
isStack = true;
|
|
226
|
-
break;
|
|
317
|
+
assignAutoClass(section, options.autoelements, 'global');
|
|
318
|
+
}
|
|
227
319
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return isStack;
|
|
320
|
+
});
|
|
231
321
|
};
|
|
232
322
|
|
|
233
323
|
if (options.compatibility) {
|
|
@@ -235,32 +325,32 @@ var Plugin = function Plugin() {
|
|
|
235
325
|
baseclass = options.compatibilitybaseclass;
|
|
236
326
|
}
|
|
237
327
|
|
|
238
|
-
|
|
239
|
-
allappearances.forEach(
|
|
328
|
+
let allappearances = deck.getRevealElement().querySelectorAll(animatecss);
|
|
329
|
+
allappearances.forEach(appearance => {
|
|
240
330
|
if (!appearance.classList.contains(baseclass)) {
|
|
241
331
|
appearance.classList.add(baseclass);
|
|
242
332
|
}
|
|
243
333
|
});
|
|
244
334
|
autoAdd();
|
|
245
|
-
sections.forEach(
|
|
335
|
+
sections.forEach(section => {
|
|
246
336
|
findAppearancesIn(section, appearanceSelector, fragmentSelector);
|
|
247
337
|
});
|
|
248
|
-
fragments.forEach(
|
|
338
|
+
fragments.forEach(fragment => {
|
|
249
339
|
findAppearancesIn(fragment, appearanceSelector, fragmentSelector);
|
|
250
340
|
});
|
|
251
341
|
|
|
252
|
-
|
|
253
|
-
|
|
342
|
+
const fromTo = function (event) {
|
|
343
|
+
let slides = {};
|
|
254
344
|
slides.from = event.fromSlide ? event.fromSlide : event.previousSlide ? event.previousSlide : null;
|
|
255
345
|
slides.to = event.toSlide ? event.toSlide : event.currentSlide ? event.currentSlide : null;
|
|
256
346
|
return slides;
|
|
257
347
|
};
|
|
258
348
|
|
|
259
|
-
|
|
349
|
+
const showHideSlide = function (event) {
|
|
260
350
|
var _slides$to;
|
|
261
351
|
|
|
262
|
-
|
|
263
|
-
|
|
352
|
+
let etype = event.type;
|
|
353
|
+
let slides = fromTo(event);
|
|
264
354
|
debugLog(etype);
|
|
265
355
|
|
|
266
356
|
if (((_slides$to = slides.to) === null || _slides$to === void 0 ? void 0 : _slides$to.dataset.appearevent) == "auto") {
|
|
@@ -276,7 +366,7 @@ var Plugin = function Plugin() {
|
|
|
276
366
|
}
|
|
277
367
|
|
|
278
368
|
if (slides.to) {
|
|
279
|
-
|
|
369
|
+
let appearevent = slides.to.dataset.appearevent ? slides.to.dataset.appearevent : options.appearevent;
|
|
280
370
|
|
|
281
371
|
if (etype == appearevent || etype == "slidetransitionend" && appearevent == "autoanimate") {
|
|
282
372
|
slides.to.dataset.appearanceCanStart = true;
|
|
@@ -284,21 +374,27 @@ var Plugin = function Plugin() {
|
|
|
284
374
|
|
|
285
375
|
if (etype == "slidetransitionend") {
|
|
286
376
|
if (options.hideagain) {
|
|
287
|
-
|
|
377
|
+
if (slides.from) {
|
|
378
|
+
if (slides.from.dataset.appearanceCanStart) {
|
|
379
|
+
delete slides.from.dataset.appearanceCanStart;
|
|
380
|
+
}
|
|
288
381
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
382
|
+
let fromFragments = slides.from.querySelectorAll(`.fragment.visible`);
|
|
383
|
+
|
|
384
|
+
if (fromFragments) {
|
|
385
|
+
fromFragments.forEach(fragment => {
|
|
386
|
+
fragment.classList.remove('visible');
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
294
390
|
}
|
|
295
391
|
}
|
|
296
392
|
|
|
297
393
|
if (event.type == 'slidechanged' && document.body.dataset.exitoverview) {
|
|
298
394
|
if (options.hideagain) {
|
|
299
|
-
var _slides$
|
|
395
|
+
var _slides$from;
|
|
300
396
|
|
|
301
|
-
(_slides$
|
|
397
|
+
(_slides$from = slides.from) === null || _slides$from === void 0 ? true : delete _slides$from.dataset.appearanceCanStart;
|
|
302
398
|
}
|
|
303
399
|
|
|
304
400
|
slides.to.dataset.appearanceCanStart = true;
|
|
@@ -310,9 +406,9 @@ var Plugin = function Plugin() {
|
|
|
310
406
|
|
|
311
407
|
if (event.currentSlide) {
|
|
312
408
|
if (options.hideagain) {
|
|
313
|
-
var _slides$
|
|
409
|
+
var _slides$from2;
|
|
314
410
|
|
|
315
|
-
(_slides$
|
|
411
|
+
(_slides$from2 = slides.from) === null || _slides$from2 === void 0 ? true : delete _slides$from2.dataset.appearanceCanStart;
|
|
316
412
|
}
|
|
317
413
|
|
|
318
414
|
slides.to.dataset.appearanceCanStart = true;
|
|
@@ -321,17 +417,15 @@ var Plugin = function Plugin() {
|
|
|
321
417
|
}
|
|
322
418
|
};
|
|
323
419
|
|
|
324
|
-
|
|
325
|
-
eventnames.forEach(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
});
|
|
329
|
-
});
|
|
420
|
+
const eventnames = ['ready', 'slidechanged', 'slidetransitionend', 'autoanimate', 'overviewhidden'];
|
|
421
|
+
eventnames.forEach(eventname => deck.on(eventname, event => {
|
|
422
|
+
showHideSlide(event);
|
|
423
|
+
}));
|
|
330
424
|
};
|
|
331
425
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
426
|
+
const init = function (deck) {
|
|
427
|
+
let es5Filename = "appearance.js";
|
|
428
|
+
let defaultOptions = {
|
|
335
429
|
baseclass: 'animate__animated',
|
|
336
430
|
hideagain: true,
|
|
337
431
|
delay: 300,
|
|
@@ -339,29 +433,30 @@ var Plugin = function Plugin() {
|
|
|
339
433
|
appearevent: 'slidetransitionend',
|
|
340
434
|
autoappear: false,
|
|
341
435
|
autoelements: false,
|
|
436
|
+
appearparents: false,
|
|
342
437
|
csspath: '',
|
|
343
438
|
animatecsspath: {
|
|
344
439
|
link: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css',
|
|
345
|
-
compat: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.
|
|
440
|
+
compat: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css'
|
|
346
441
|
},
|
|
347
442
|
compatibility: false,
|
|
348
443
|
compatibilitybaseclass: 'animated'
|
|
349
444
|
};
|
|
350
445
|
|
|
351
|
-
|
|
352
|
-
for (
|
|
446
|
+
const defaults = function (options, defaultOptions) {
|
|
447
|
+
for (let i in defaultOptions) {
|
|
353
448
|
if (!options.hasOwnProperty(i)) {
|
|
354
449
|
options[i] = defaultOptions[i];
|
|
355
450
|
}
|
|
356
451
|
}
|
|
357
452
|
};
|
|
358
453
|
|
|
359
|
-
|
|
454
|
+
let options = deck.getConfig().appearance || {};
|
|
360
455
|
defaults(options, defaultOptions);
|
|
361
456
|
|
|
362
457
|
function pluginPath() {
|
|
363
|
-
|
|
364
|
-
|
|
458
|
+
let path;
|
|
459
|
+
let pluginScript = document.querySelector(`script[src$="${es5Filename}"]`);
|
|
365
460
|
|
|
366
461
|
if (pluginScript) {
|
|
367
462
|
path = pluginScript.getAttribute("src").slice(0, -1 * es5Filename.length);
|
|
@@ -372,14 +467,14 @@ var Plugin = function Plugin() {
|
|
|
372
467
|
return path;
|
|
373
468
|
}
|
|
374
469
|
|
|
375
|
-
|
|
376
|
-
|
|
470
|
+
let AppearanceStylePath = options.csspath.appearance ? options.csspath.appearance : `${pluginPath()}appearance.css` || 'plugin/appearance/appearance.css';
|
|
471
|
+
let AnimateCSSPath = !options.compatibility ? options.animatecsspath.link : options.animatecsspath.compat;
|
|
377
472
|
|
|
378
473
|
if (options.debug) {
|
|
379
|
-
console.log(
|
|
380
|
-
console.log(
|
|
381
|
-
console.log(
|
|
382
|
-
console.log(
|
|
474
|
+
console.log(`Plugin path = ${pluginPath()}`);
|
|
475
|
+
console.log(`Compatibility mode: ${options.compatibility}`);
|
|
476
|
+
console.log(`Appearance CSS path = ${AppearanceStylePath}`);
|
|
477
|
+
console.log(`AnimateCSS CSS path = ${AnimateCSSPath}`);
|
|
383
478
|
}
|
|
384
479
|
|
|
385
480
|
loadStyle(AnimateCSSPath, 'stylesheet', function () {
|