mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
refactor(code-snippet): use afterUpdate
This commit is contained in:
parent
6a28583a85
commit
152cbcd1ab
1 changed files with 5 additions and 3 deletions
|
@ -11,6 +11,7 @@
|
|||
export let light = false;
|
||||
export let style = undefined;
|
||||
|
||||
import { afterUpdate } from 'svelte';
|
||||
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
|
||||
import { cx } from '../../lib';
|
||||
import Button from '../Button';
|
||||
|
@ -22,10 +23,11 @@
|
|||
let expanded = false;
|
||||
let showMoreLess = false;
|
||||
|
||||
$: expandText = expanded ? showLessText : showMoreText;
|
||||
$: if (codeRef) {
|
||||
afterUpdate(() => {
|
||||
showMoreLess = type === 'multi' && codeRef.getBoundingClientRect().height > 255;
|
||||
}
|
||||
});
|
||||
|
||||
$: expandText = expanded ? showLessText : showMoreText;
|
||||
</script>
|
||||
|
||||
{#if type === 'inline'}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue