set background from SVG's pagecolor attr, default to black
This commit is contained in:
parent
77e20afc61
commit
b3212c6c6a
2 changed files with 20 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<SVGContent id="root" url="content/intro.svg" edge-scrolling />
|
<SVGContent id="root" url="content/intro.svg" edge-scrolling @set-background="setBackground"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -11,6 +11,11 @@ export default defineComponent({
|
||||||
name: "App",
|
name: "App",
|
||||||
components: {
|
components: {
|
||||||
SVGContent
|
SVGContent
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setBackground(background: string) {
|
||||||
|
document.body.style.background = background;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -18,7 +23,10 @@ export default defineComponent({
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: white;
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body, #app, #root {
|
html, body, #app, #root {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
edgeScrolling: Boolean
|
edgeScrolling: Boolean
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props, {emit}) {
|
||||||
const root = ref(null);
|
const root = ref(null);
|
||||||
const panzoom = ref<null | PanZoom>(null);
|
const panzoom = ref<null | PanZoom>(null);
|
||||||
const anchors = ref<SVGRectElement[]>([]);
|
const anchors = ref<SVGRectElement[]>([]);
|
||||||
|
@ -36,6 +36,15 @@ export default defineComponent({
|
||||||
const svgParsed = new DOMParser().parseFromString(await fetchResult.text(), "image/svg+xml") as Document;
|
const svgParsed = new DOMParser().parseFromString(await fetchResult.text(), "image/svg+xml") as Document;
|
||||||
const svg = element.appendChild(svgParsed.firstElementChild as Element) as any;
|
const svg = element.appendChild(svgParsed.firstElementChild as Element) as any;
|
||||||
|
|
||||||
|
// Set document background
|
||||||
|
const svgBaseEl = svg.getElementById("base");
|
||||||
|
if (svgBaseEl) {
|
||||||
|
const pageColor = svgBaseEl.attributes.getNamedItem("pagecolor");
|
||||||
|
if (pageColor) {
|
||||||
|
emit("setBackground", pageColor.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PanZoom
|
// PanZoom
|
||||||
const pz = createPanZoom(element, {
|
const pz = createPanZoom(element, {
|
||||||
smoothScroll: false,
|
smoothScroll: false,
|
||||||
|
|
Loading…
Reference in a new issue