fix(tile): set max height using aboveRef only if value is 0

Fixes #180
This commit is contained in:
Eric Liu 2020-05-09 07:23:06 -07:00
commit 662c7b7fde

View file

@ -11,7 +11,7 @@
export let tileMaxHeight = 0; export let tileMaxHeight = 0;
export let tilePadding = 0; export let tilePadding = 0;
import { onMount, afterUpdate } from 'svelte'; import { afterUpdate } from 'svelte';
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16'; import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
import { cx, css } from '../../lib'; import { cx, css } from '../../lib';
@ -19,20 +19,17 @@
let contentRef = undefined; let contentRef = undefined;
let aboveRef = undefined; let aboveRef = undefined;
onMount(() => { afterUpdate(() => {
const style = window.getComputedStyle(tileRef); if (tileMaxHeight === 0) {
tileMaxHeight = aboveRef.getBoundingClientRect().height;
}
tileMaxHeight = aboveRef.getBoundingClientRect().height; const style = window.getComputedStyle(tileRef);
tilePadding = tilePadding =
parseInt(style.getPropertyValue('padding-top'), 10) + parseInt(style.getPropertyValue('padding-top'), 10) +
parseInt(style.getPropertyValue('padding-bottom'), 10); parseInt(style.getPropertyValue('padding-bottom'), 10);
}); });
afterUpdate(() => {
tileMaxHeight = expanded
? contentRef.getBoundingClientRect().height
: aboveRef.getBoundingClientRect().height;
});
</script> </script>
<div <div