Skip to content

Commit fe0eb9b

Browse files
committed
refactor: change 'await' for '.then()' in some functions
in order not to propage the async through the functions call chain
1 parent 07f8617 commit fe0eb9b

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

js-css-animations/animate.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ const getAction = (element, animType) => {
484484
* @param {HTMLElement} el - The DOM element being animated
485485
* @param {Object} args - The animation's ID and type and all the options passed by the user
486486
*/
487-
const preset = async (el, args) => {
487+
const preset = (el, args) => {
488488
const { opts, animationId } = args;
489489
const { animType } = opts;
490490
if (
@@ -495,14 +495,14 @@ const preset = async (el, args) => {
495495
)
496496
opts.angle = undefined;
497497

498-
await updateCssProperties(el, opts);
499-
500-
if (opts.staggerDelay) {
501-
const staggeredDelay =
502-
getTimeInMs(opts.delay) +
503-
getTimeInMs(opts.staggerDelay) * opts.queryIndex;
504-
setCssProperty(el, 'delay', `${staggeredDelay}ms`);
505-
}
498+
updateCssProperties(el, opts).then(() => {
499+
if (opts.staggerDelay) {
500+
const staggeredDelay =
501+
getTimeInMs(opts.delay) +
502+
getTimeInMs(opts.staggerDelay) * opts.queryIndex;
503+
setCssProperty(el, 'delay', `${staggeredDelay}ms`);
504+
}
505+
});
506506
};
507507

508508
/**

js-css-animations/js-css-animations.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ const getTargets = selector => {
6969
* @see {@link module:globals.PROPERTY_NAMES}
7070
* @see {@link module:animate~configurations}
7171
*/
72-
const config = async opts => {
72+
const config = opts => {
7373
updateDefaultConfig(opts);
74-
await updateCssProperties(document.documentElement, opts);
75-
if (opts.cursor)
76-
setCssProperty(document.documentElement, 'cursor', opts.cursor);
74+
updateCssProperties(document.documentElement, opts).then(() => {
75+
if (opts.cursor)
76+
setCssProperty(document.documentElement, 'cursor', opts.cursor);
77+
});
7778
};
7879

7980
/**
@@ -190,10 +191,10 @@ const animationFunctions = (function () {
190191
'dimensionsTransition',
191192
].forEach(opt => (args[opt] = opts[opt]));
192193

193-
getTargets(target).forEach(async (element, i) => {
194+
getTargets(target).forEach((element, i) => {
194195
opts.animType = animType;
195196
opts.queryIndex = i;
196-
await preset(element, {
197+
preset(element, {
197198
opts,
198199
animationId: id,
199200
});

0 commit comments

Comments
 (0)