Skip to content

Commit f942342

Browse files
committed
refactor: remove unused code from animate.js
this code is now being accessed through the AnimationHandler classes
1 parent 7f3f91c commit f942342

File tree

1 file changed

+0
-155
lines changed

1 file changed

+0
-155
lines changed

js-css-animations/animate.js

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ import {
99
CUSTOM_CSS_PROPERTIES,
1010
} from './globals.js';
1111

12-
// import { initParentResize, endParentResize } from './resize-parent.js';
13-
14-
// import {
15-
// // removeInlineTransition,
16-
// // appendTransition,
17-
// // getCurrentTransition,
18-
// } from './transitions.js';
19-
20-
// import { setParentMaxMeasures } from './measurements.js';
21-
2212
/**
2313
* Contains the default value for each custom option.
2414
* Those values can be overwritten by the user by calling jsCssAnimations.config()
@@ -293,20 +283,6 @@ const isVisibility = animType => animType === 'visibility';
293283
*/
294284
const isMotion = animType => animType === 'motion';
295285

296-
/**
297-
* Removes the current motion animation CSS class from the element
298-
* @param {HTMLElement} element - The DOM element being animated
299-
*/
300-
const removeMotionCssClass = element => {
301-
const className = [...element.classList].find(cl =>
302-
cl.match(/js\-anim\-\-(rotate|scale)/)
303-
);
304-
if (className) element.classList.remove(className);
305-
if (className === CLASS_NAMES.move[MOTION_ANIMS_ID.rotate]) {
306-
element.style.removeProperty(PROPERTY_NAMES.angle);
307-
}
308-
};
309-
310286
/**
311287
* Sets an attribute to indicate that the element is currently being animated
312288
* and so can not perform any other animations
@@ -332,14 +308,6 @@ const enable = element => {
332308
const isEnabled = element =>
333309
!(element.getAttribute('js-anim--disabled') === 'true');
334310

335-
/**
336-
* Adds a CSS class which will set the overflow property to 'clip' (or 'hidden')
337-
* @param {HTMLElement} el - The DOM element which will receive the CSS class
338-
*/
339-
const setOverflowHidden = el => {
340-
el.classList.add(CLASS_NAMES.overflowHidden);
341-
};
342-
343311
/**
344312
* Removes the CSS class which sets the overflow property to 'clip' (or 'hidden')
345313
* @param {HTMLElement} el - The DOM element with the CSS class to remove
@@ -348,62 +316,6 @@ const removeOverflowHidden = el => {
348316
el.classList.remove(CLASS_NAMES.overflowHidden);
349317
};
350318

351-
/**
352-
* Verifies if an element has defined an iteration CSS property
353-
* @param {HTMLElement} element
354-
* @returns True if the element has an iteration CSS property set, False otherwise
355-
*/
356-
const hasIterationProp = element => {
357-
const iterationProperty = element.style.getPropertyValue(
358-
PROPERTY_NAMES.iteration
359-
);
360-
return (
361-
iterationProperty != '1' &&
362-
iterationProperty.match(/^(infinite|\d+)$/) !== null
363-
);
364-
};
365-
366-
/**
367-
* Sets the parent element dimensions, if needed.
368-
*
369-
* Removes the collapsed or hidden class from the element, when necessary
370-
* @param {HTMLElement} element - The DOM element being animated
371-
* @param {{
372-
* parentState: string,
373-
* element: HTMLElement,
374-
* parentMeasures: Object,
375-
* action: string,
376-
* dimension: string | undefined
377-
* }} args - All the necessary arguments
378-
*/
379-
const handleVisibilityToggle = (element, args) => {
380-
setTimeout(() => {
381-
if (args.dimension) setParentMaxMeasures(args);
382-
if (args.action === 'show') {
383-
element.classList.remove(CLASS_NAMES.hidden, CLASS_NAMES.collapsed);
384-
}
385-
}, 0);
386-
};
387-
388-
/**
389-
* Adds the hidden or collapsed class, when necessary.
390-
* Finalize parent element's resize operations, if needed.
391-
* @param {HTMLElement} element - The DOM element being animated
392-
* @param {Object} opts - All the necessary options
393-
*/
394-
const endVisibilityToggle = (element, opts) => {
395-
if (opts.action === 'hide') {
396-
opts.maintainSpace
397-
? element.classList.add(CLASS_NAMES.hidden)
398-
: element.classList.add(CLASS_NAMES.collapsed);
399-
}
400-
if (opts.heightTransition || opts.widthTransition)
401-
endParentResize(element, opts);
402-
403-
if (opts.overflowHidden && element.parentElement)
404-
removeOverflowHidden(element.parentElement);
405-
};
406-
407319
/**
408320
* Executes a given callback, checking, when necessary, if the callback was already
409321
* executed by another element being animated by the same trigger button
@@ -503,7 +415,6 @@ const animate = async (element, action, id, opts = {}) => {
503415
move: 'moveBack',
504416
moveBack: 'move',
505417
});
506-
// let parentMeasures, dimension, currentTransition;
507418

508419
if (trigger) TARGETS_STACK.add(element, trigger);
509420

@@ -517,72 +428,6 @@ const animate = async (element, action, id, opts = {}) => {
517428
maintainSpace,
518429
});
519430

520-
// const handleAnimation = {
521-
// begining: {
522-
// visibility: () => {
523-
// if (widthTransition || heightTransition) {
524-
// ({ parentMeasures, dimension } = initParentResize({
525-
// element,
526-
// action,
527-
// widthTransition,
528-
// heightTransition,
529-
// }));
530-
// }
531-
532-
// if (overflowHidden && element.parentElement)
533-
// setOverflowHidden(element.parentElement);
534-
// },
535-
// motion: () => {
536-
// currentTransition = getCurrentTransition(element);
537-
// removeMotionCssClass(element);
538-
// },
539-
// },
540-
// middle: {
541-
// visibility: () => {
542-
// handleVisibilityToggle(element, {
543-
// parentState: 'final',
544-
// element,
545-
// parentMeasures,
546-
// action,
547-
// dimension,
548-
// });
549-
// },
550-
// motion: () => {
551-
// if (currentTransition) {
552-
// appendTransition(element, CLASS_NAMES[action][id], currentTransition);
553-
// }
554-
// if (action === 'move') element.classList.add(CLASS_NAMES.moved);
555-
// },
556-
// },
557-
// end: {
558-
// visibility: () => {
559-
// endVisibilityToggle(element, {
560-
// action,
561-
// maintainSpace,
562-
// widthTransition,
563-
// heightTransition,
564-
// overflowHidden,
565-
// });
566-
// if (!hasIterationProp(element))
567-
// element.classList.remove(CLASS_NAMES[action][id]);
568-
// },
569-
// motion: () => {
570-
// if (action === 'moveBack') element.classList.remove(CLASS_NAMES.moved);
571-
// },
572-
// },
573-
// conclude: () => {
574-
// if (trigger && opts.queryIndex === opts.totalTargets - 1) {
575-
// opts.staggerDelay
576-
// ? CALLBACK_TRACKER.remove(trigger)
577-
// : setTimeout(() => CALLBACK_TRACKER.remove(trigger), delay);
578-
// TARGETS_STACK.get(trigger).forEach(el => enable(el));
579-
// TARGETS_STACK.remove(trigger);
580-
// } else if (!trigger) {
581-
// enable(element);
582-
// }
583-
// },
584-
// };
585-
586431
const concludeAnimation = () => {
587432
if (trigger && opts.queryIndex === opts.totalTargets - 1) {
588433
opts.staggerDelay

0 commit comments

Comments
 (0)