Skip to content

Commit 6dcc71f

Browse files
committed
docs: update documentation
1 parent 3624f8b commit 6dcc71f

13 files changed

+388
-93
lines changed

jsdoc/doc/animate.js.html

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ <h1 class="page-title">Source: animate.js</h1>
3737
CUSTOM_CSS_PROPERTIES,
3838
} from './globals.js';
3939

40-
import { initParentResize, endParentResize } from './resize-parent.js';
40+
import {
41+
initParentResize,
42+
endParentResize,
43+
setOverflowHidden,
44+
removeOverflowHidden,
45+
} from './resize-parent.js';
4146

4247
import {
4348
removeInlineTransition,
@@ -60,7 +65,7 @@ <h1 class="page-title">Source: animate.js</h1>
6065
staggerDelay: undefined,
6166
start: undefined,
6267
complete: undefined,
63-
keepSpace: false,
68+
maintainSpace: false,
6469
dimensionsTransition: true,
6570
widthTransition: undefined,
6671
heightTransition: undefined,
@@ -175,6 +180,12 @@ <h1 class="page-title">Source: animate.js</h1>
175180
stack: {},
176181
};
177182

183+
/**
184+
* Keeps track of the EventListeners associated to a trigger selector
185+
* @type {{[x: String]: EventListener[]}}
186+
*/
187+
const LISTENERS = {};
188+
178189
/**
179190
* Removes the CSS properties customized by the user
180191
* @param {HTMLElement} element - The DOM element with the custom CSS properties
@@ -354,10 +365,12 @@ <h1 class="page-title">Source: animate.js</h1>
354365
* @returns True if the element has an iteration CSS property set, False otherwise
355366
*/
356367
const hasIterationProp = element => {
368+
const iterationProperty = element.style.getPropertyValue(
369+
PROPERTY_NAMES.iteration
370+
);
357371
return (
358-
element.style
359-
.getPropertyValue(PROPERTY_NAMES.iteration)
360-
.match(/^(infinite|\d+)$/) !== null
372+
iterationProperty != '1' &amp;&amp;
373+
iterationProperty.match(/^(infinite|\d+)$/) !== null
361374
);
362375
};
363376

@@ -371,17 +384,14 @@ <h1 class="page-title">Source: animate.js</h1>
371384
* element: HTMLElement,
372385
* parentMeasures: Object,
373386
* action: string,
374-
* dimension: string | undefined,
375-
* keepSpace: boolean
387+
* dimension: string | undefined
376388
* }} args - All the necessary arguments
377389
*/
378390
const handleVisibilityToggle = (element, args) => {
379391
setTimeout(() => {
380392
if (args.dimension) setParentMaxMeasures(args);
381393
if (args.action === 'show') {
382-
args.keepSpace
383-
? element.classList.remove(CLASS_NAMES.hidden)
384-
: element.classList.remove(CLASS_NAMES.collapsed);
394+
element.classList.remove(CLASS_NAMES.hidden, CLASS_NAMES.collapsed);
385395
}
386396
}, 0);
387397
};
@@ -394,12 +404,14 @@ <h1 class="page-title">Source: animate.js</h1>
394404
*/
395405
const endVisibilityToggle = (element, opts) => {
396406
if (opts.action === 'hide') {
397-
opts.keepSpace
407+
opts.maintainSpace
398408
? element.classList.add(CLASS_NAMES.hidden)
399409
: element.classList.add(CLASS_NAMES.collapsed);
400410
}
401411
if (opts.heightTransition || opts.widthTransition)
402412
endParentResize(element, opts);
413+
else if (opts.overflowHidden &amp;&amp; element.parentElement)
414+
removeOverflowHidden(element.parentElement);
403415
};
404416

405417
/**
@@ -442,8 +454,8 @@ <h1 class="page-title">Source: animate.js</h1>
442454
trigger,
443455
start = CONFIG.start,
444456
complete = CONFIG.complete,
445-
keepSpace = CONFIG.keepSpace,
446-
dimensionsTransition = keepSpace || isMotion(animType)
457+
maintainSpace = CONFIG.maintainSpace,
458+
dimensionsTransition = maintainSpace || isMotion(animType)
447459
? false
448460
: CONFIG.dimensionsTransition,
449461
widthTransition = CONFIG.widthTransition ?? dimensionsTransition,
@@ -472,7 +484,8 @@ <h1 class="page-title">Source: animate.js</h1>
472484
heightTransition,
473485
overflowHidden,
474486
}));
475-
}
487+
} else if (overflowHidden &amp;&amp; element.parentElement)
488+
setOverflowHidden(element.parentElement);
476489
},
477490
motion: () => {
478491
currentTransition = getCurrentTransition(element);
@@ -487,7 +500,6 @@ <h1 class="page-title">Source: animate.js</h1>
487500
parentMeasures,
488501
action,
489502
dimension,
490-
keepSpace,
491503
});
492504
},
493505
motion: () => {
@@ -501,9 +513,10 @@ <h1 class="page-title">Source: animate.js</h1>
501513
visibility: () => {
502514
endVisibilityToggle(element, {
503515
action,
504-
keepSpace,
516+
maintainSpace,
505517
widthTransition,
506518
heightTransition,
519+
overflowHidden,
507520
});
508521
if (!hasIterationProp(element))
509522
element.classList.remove(CLASS_NAMES[action][id]);
@@ -595,7 +608,7 @@ <h1 class="page-title">Source: animate.js</h1>
595608
* @param {HTMLElement} el - The DOM element being animated
596609
* @param {number} animationId - The ID of the animation in the *_ANIMS_ID
597610
* @param {Object} opts - The options passed by the user
598-
* @returns A function to be passed to the addEventListener() as a handler
611+
* @returns {EventListener} A function to be passed to the addEventListener() as a handler
599612
* @see {@link module:globals.VISIBILITY_ANIMS_ID}
600613
* @see {@link module:globals.MOTION_ANIMS_ID}
601614
*/
@@ -647,24 +660,48 @@ <h1 class="page-title">Source: animate.js</h1>
647660
btn.setAttribute('target-selector', targetSelector);
648661
}
649662

663+
if (!opts.trigger) opts.trigger = trigger;
664+
LISTENERS[trigger] = [];
650665
document
651666
.querySelectorAll(getTargetSelector(btn))
652667
.forEach((el, i, queryList) => {
653-
btn.addEventListener(
654-
eventType,
655-
// @ts-ignore
656-
eventHandler(el, animationId, {
657-
...opts,
658-
totalTargets: queryList.length,
659-
queryIndex: i,
660-
})
661-
);
668+
// @ts-ignore
669+
const listener = eventHandler(el, animationId, {
670+
...opts,
671+
totalTargets: queryList.length,
672+
queryIndex: i,
673+
});
674+
675+
LISTENERS[trigger].push(listener);
676+
btn.addEventListener(eventType, listener);
662677
});
663678
});
664679
};
665680

681+
/**
682+
* Removes the event listener of all elements represented by the `triggerSelector`
683+
* @param {String|null} triggerSelector - A valid CSS selector for the trigger Element. If ommited, '.${CLASS_NAMES.trigger}' will be used instead.
684+
* @param {String} eventType - The event name. If ommited, 'click' is the default value.
685+
*/
686+
const end = (triggerSelector = null, eventType = 'click') => {
687+
const triggerList =
688+
typeof triggerSelector === 'string'
689+
? document.querySelectorAll(triggerSelector)
690+
: document.querySelectorAll(`.${CLASS_NAMES.trigger}`);
691+
692+
triggerList.forEach(trigger => {
693+
LISTENERS[triggerSelector ?? `.${CLASS_NAMES.trigger}`].forEach(
694+
listener => {
695+
trigger.removeEventListener(eventType, listener);
696+
}
697+
);
698+
});
699+
delete LISTENERS[triggerSelector ?? `.${CLASS_NAMES.trigger}`];
700+
};
701+
666702
export {
667703
init,
704+
end,
668705
animate,
669706
preset,
670707
isEnabled,
@@ -688,7 +725,7 @@ <h2><a href="index.html">JS-CSS Animations</a></h2><h3>Modules</h3><ul><li><a hr
688725
<br class="clear">
689726

690727
<footer>
691-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Nov 23 2022 20:32:22 GMT-0300 (Horário Padrão de Brasília)
728+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Dec 07 2022 15:22:18 GMT-0300 (Horário Padrão de Brasília)
692729
</footer>
693730

694731
<script> prettyPrint(); </script>

jsdoc/doc/globals.js.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h1 class="page-title">Source: globals.js</h1>
8181
*/
8282
export const PROPERTY_NAMES = Object.freeze({
8383
duration: '--js-css-animation--duration',
84-
timingFunction: '--js-css-animation--timing-function',
84+
easing: '--js-css-animation--timing-function',
8585
delay: '--js-css-animation--delay',
8686
fillMode: '--js-css-animation--fill-mode',
8787
cursor: '--js-css-animation--cursor',
@@ -193,7 +193,7 @@ <h2><a href="index.html">JS-CSS Animations</a></h2><h3>Modules</h3><ul><li><a hr
193193
<br class="clear">
194194

195195
<footer>
196-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Nov 23 2022 20:32:22 GMT-0300 (Horário Padrão de Brasília)
196+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Dec 07 2022 15:22:18 GMT-0300 (Horário Padrão de Brasília)
197197
</footer>
198198

199199
<script> prettyPrint(); </script>

jsdoc/doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2><a href="index.html">JS-CSS Animations</a></h2><h3>Modules</h3><ul><li><a hr
5656
<br class="clear">
5757

5858
<footer>
59-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Nov 23 2022 20:32:22 GMT-0300 (Horário Padrão de Brasília)
59+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Dec 07 2022 15:22:18 GMT-0300 (Horário Padrão de Brasília)
6060
</footer>
6161

6262
<script> prettyPrint(); </script>

jsdoc/doc/js-css-animations.js.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h1 class="page-title">Source: js-css-animations.js</h1>
3232
*/
3333
import {
3434
init,
35+
end,
3536
animate,
3637
preset,
3738
isEnabled,
@@ -126,11 +127,11 @@ <h1 class="page-title">Source: js-css-animations.js</h1>
126127
* duration: number|string|undefined,
127128
* delay: number|string|undefined,
128129
* staggerDelay: number|string|undefined,
129-
* timingFunction: string|undefined,
130+
* easing: string|undefined,
130131
* blur: string|undefined,
131132
* angle: string|undefined,
132133
* iteration: string|undefined,
133-
* keepSpace: boolean|undefined,
134+
* maintainSpace: boolean|undefined,
134135
* overflowHidden: boolean|undefined,
135136
* dimensionsTransition: boolean|undefined,
136137
* widthTransition: boolean|undefined,
@@ -143,13 +144,13 @@ <h1 class="page-title">Source: js-css-animations.js</h1>
143144
'duration',
144145
'delay',
145146
'staggerDelay',
146-
'timingFunction',
147+
'easing',
147148
'blur',
148149
'angle',
149150
'iteration',
150151
'direction',
151152
'transfOrigin',
152-
'keepSpace',
153+
'maintainSpace',
153154
'overflowHidden',
154155
'dimensionsTransition',
155156
'widthTransition',
@@ -209,7 +210,7 @@ <h1 class="page-title">Source: js-css-animations.js</h1>
209210
[
210211
'start',
211212
'complete',
212-
'keepSpace',
213+
'maintainSpace',
213214
'overflowHidden',
214215
'staggerDelay',
215216
'widthTransition',
@@ -365,6 +366,7 @@ <h1 class="page-title">Source: js-css-animations.js</h1>
365366
const animationsHandler = Object.freeze({
366367
config,
367368
reset,
369+
end,
368370
init: eventAnimations,
369371
...animationFunctions,
370372
show: showVisibilityAnim,
@@ -403,7 +405,7 @@ <h2><a href="index.html">JS-CSS Animations</a></h2><h3>Modules</h3><ul><li><a hr
403405
<br class="clear">
404406

405407
<footer>
406-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Nov 23 2022 20:32:22 GMT-0300 (Horário Padrão de Brasília)
408+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Dec 07 2022 15:22:18 GMT-0300 (Horário Padrão de Brasília)
407409
</footer>
408410

409411
<script> prettyPrint(); </script>

jsdoc/doc/measurements.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ <h2><a href="index.html">JS-CSS Animations</a></h2><h3>Modules</h3><ul><li><a hr
273273
<br class="clear">
274274

275275
<footer>
276-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Nov 23 2022 20:32:22 GMT-0300 (Horário Padrão de Brasília)
276+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed Dec 07 2022 15:22:18 GMT-0300 (Horário Padrão de Brasília)
277277
</footer>
278278

279279
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)