Skip to content

Commit 107b61c

Browse files
committed
fix: 'overflow' CSS property being properly set and removed
even when there's no dimensions transitions to be performed on the parent element before this fix, the 'overflow' property was being set/removed only when any dimension transition was being applied to parent element
1 parent 4f69138 commit 107b61c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

js-css-animations/animate.js

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

12-
import { initParentResize, endParentResize } from './resize-parent.js';
12+
import {
13+
initParentResize,
14+
endParentResize,
15+
setOverflowHidden,
16+
removeOverflowHidden,
17+
} from './resize-parent.js';
1318

1419
import {
1520
removeInlineTransition,
@@ -332,10 +337,12 @@ const isEnabled = element =>
332337
* @returns True if the element has an iteration CSS property set, False otherwise
333338
*/
334339
const hasIterationProp = element => {
340+
const iterationProperty = element.style.getPropertyValue(
341+
PROPERTY_NAMES.iteration
342+
);
335343
return (
336-
element.style
337-
.getPropertyValue(PROPERTY_NAMES.iteration)
338-
.match(/^(infinite|\d+)$/) !== null
344+
iterationProperty != '1' &&
345+
iterationProperty.match(/^(infinite|\d+)$/) !== null
339346
);
340347
};
341348

@@ -375,6 +382,8 @@ const endVisibilityToggle = (element, opts) => {
375382
}
376383
if (opts.heightTransition || opts.widthTransition)
377384
endParentResize(element, opts);
385+
else if (opts.overflowHidden && element.parentElement)
386+
removeOverflowHidden(element.parentElement);
378387
};
379388

380389
/**
@@ -447,7 +456,8 @@ const animate = (element, action, id, opts = {}) => {
447456
heightTransition,
448457
overflowHidden,
449458
}));
450-
}
459+
} else if (overflowHidden && element.parentElement)
460+
setOverflowHidden(element.parentElement);
451461
},
452462
motion: () => {
453463
currentTransition = getCurrentTransition(element);
@@ -478,6 +488,7 @@ const animate = (element, action, id, opts = {}) => {
478488
keepSpace,
479489
widthTransition,
480490
heightTransition,
491+
overflowHidden,
481492
});
482493
if (!hasIterationProp(element))
483494
element.classList.remove(CLASS_NAMES[action][id]);

js-css-animations/resize-parent.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,9 @@ const endParentResize = (element, opts) => {
127127
removeOverflowHidden(parentElement);
128128
};
129129

130-
export { initParentResize, endParentResize };
130+
export {
131+
initParentResize,
132+
endParentResize,
133+
setOverflowHidden,
134+
removeOverflowHidden,
135+
};

0 commit comments

Comments
 (0)