Skip to content

Commit

Permalink
chore: adds resize observer to playground
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Nov 23, 2023
1 parent fcdc3d6 commit 99733c3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions docs/components/CodeExample.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const stopWatch = watch(el, () => {
stopWatch()
let ignoreEvent = false
function updateHeight() {
function updateSize() {
const width = container.clientWidth
const contentHeight = Math.min(1000, editor.getContentHeight())
container.style.height = `${contentHeight}px`
Expand All @@ -42,29 +42,31 @@ const stopWatch = watch(el, () => {
}
}
new ResizeObserver(updateSize).observe(el.value)
editor.onDidChangeModelContent(() => {
code.value = editor.getValue()
updateHeight()
updateSize()
})
function runInsideWorker(code: string) {
var blob = new Blob(["self.onmessage = ", code], {
const blob = new Blob(["self.onmessage = ", code], {
type: "text/javascript",
})
var url = URL.createObjectURL(blob)
const url = URL.createObjectURL(blob)
}
updateHeight()
updateSize()
})
</script>

<template>
<div class="p-4 rounded-md bg-slate-100 dark:bg-slate-800">
<div class="rounded-md bg-slate-100 dark:bg-slate-800">
<div class="chrome" ref="el"></div>
</div>
</template>

<style scoped>
.chrome {
width: 500px;
width: 100%;
height: 200px;
}
</style>

0 comments on commit 99733c3

Please sign in to comment.