comparison client/src/lib/mixins.js @ 3500:5c4f117d8f98

diagram mixin: prevent null errors
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 28 May 2019 11:25:34 +0200
parents afab8d87932c
children 067ad32fba69
comparison
equal deleted inserted replaced
3499:3d273d76a963 3500:5c4f117d8f98
34 export const diagram = { 34 export const diagram = {
35 methods: { 35 methods: {
36 getDimensions({ main, nav }) { 36 getDimensions({ main, nav }) {
37 //dimensions and margins 37 //dimensions and margins
38 const elem = document.querySelector("#" + this.containerId); 38 const elem = document.querySelector("#" + this.containerId);
39 const svgWidth = elem ? elem.clientWidth : 0; 39 const svgWidth = elem != null ? elem.clientWidth : 0;
40 const svgHeight = elem ? elem.clientHeight : 0; 40 const svgHeight = elem != null ? elem.clientHeight : 0;
41 const mainMargin = main || { top: 20, right: 20, bottom: 110, left: 80 }; 41 const mainMargin = main || { top: 20, right: 20, bottom: 110, left: 80 };
42 const navMargin = nav || { 42 const navMargin = nav || {
43 top: svgHeight - mainMargin.top - 65, 43 top: svgHeight - mainMargin.top - 65,
44 right: 20, 44 right: 20,
45 bottom: 30, 45 bottom: 30,