Skip to content

Commit

Permalink
Issue #8 update SVG dimensions in the store when enabling timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
janpasek97 committed Dec 8, 2021
1 parent 2374e35 commit 17fa8e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions sources/frontend/src/components/SvgShowcase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:edges="this.$store.state.edges"
:excluded-vertices-boxes="this.$store.state.excludedNodesClientRects"
:vertex_map="this.$store.state.vertex_map"
:showing-timeline="this.$store.state.showTimeline"
:style="this.$store.state.style"/>
</div>
<div class="canvas-minimap-container p-0 col-md-3" style="opacity: 0.9">
Expand Down
21 changes: 16 additions & 5 deletions sources/frontend/src/components/svg/SvgCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
edges: Array,
vertices: Array,
excludedVerticesBoxes: Object,
showingTimeline: Boolean,
vertex_map: Object,
style: {
line: Object,
Expand Down Expand Up @@ -115,10 +116,7 @@ export default {
svgElem.addEventListener("mousedown", this.onMouseDownEvent);
svgElem.addEventListener("mouseup", this.onMouseUpEvent);
// once mounted set real viewport dimensions based on the dimensions of the main SVG element
this.setViewPortDimensions({
width: svgElem.clientWidth,
height: svgElem.clientHeight
})
this.onViewResizeEvent();
},
methods: {
...mapActions(["updateScale", "toggleVertexHighlightState", "changeTranslation", "changeVertexPos", "vertexMouseDown", "setViewPortDimensions", "vertexClicked"]),
Expand Down Expand Up @@ -161,8 +159,21 @@ export default {
},
onVertexMouseDown(down, vertex) {
this.vertexMouseDown({vertex, down})
},
onViewResizeEvent() {
let id = `${this.id}`
let svgElem = document.getElementById(id)
this.setViewPortDimensions({
width: svgElem.clientWidth,
height: svgElem.clientHeight
})
}
},
watch: {
showingTimeline: function(newValue) {
console.log("Showing timeline " + newValue);
this.onViewResizeEvent();
}
}
}
</script>
Expand Down

0 comments on commit 17fa8e8

Please sign in to comment.