refactor(code-snippet): replace afterUpdate with reactive statement

This commit is contained in:
Eric Liu 2020-08-08 15:49:49 -07:00
commit 4bbc50c460

View file

@ -86,7 +86,6 @@
*/ */
export let ref = null; export let ref = null;
import { afterUpdate } from "svelte";
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16"; import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
import { Button } from "../Button"; import { Button } from "../Button";
import { Copy } from "../Copy"; import { Copy } from "../Copy";
@ -94,12 +93,9 @@
import CodeSnippetSkeleton from "./CodeSnippet.Skeleton.svelte"; import CodeSnippetSkeleton from "./CodeSnippet.Skeleton.svelte";
$: expandText = expanded ? showLessText : showMoreText; $: expandText = expanded ? showLessText : showMoreText;
$: if (type === "multi" && ref) {
afterUpdate(() => { showMoreLess = ref.getBoundingClientRect().height > 255;
if (type === "multi" && ref) { }
showMoreLess = ref.getBoundingClientRect().height > 255;
}
});
</script> </script>
{#if skeleton} {#if skeleton}