Charts: Force re-render on device orientation change (#2706)

Fixes #2702.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
(cherry picked from commit f7f04bf18c)
4.2.x
Florian Hotze 2024-08-12 14:45:48 +02:00
parent 0aae365b6f
commit 668538eb9f
No known key found for this signature in database
GPG Key ID: 8EF0C2AAF35F4FC4
1 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,6 @@
<template>
<oh-chart
v-if="!rerender"
class="oh-chart-page-chart"
:class="{ 'with-tabbar': context.tab, 'with-toolbar': context.analyzer }"
:style="(this.$f7.data.themeOptions.dark === 'dark') ? 'background-color: black;' : 'background-color: white;'"
@ -31,6 +32,25 @@ export default {
components: {
OhChart
},
widget: OhChartPageDefinition
widget: OhChartPageDefinition,
data () {
return {
rerender: false
}
},
methods: {
onOrientationChange () {
this.rerender = true
this.$nextTick(() => {
this.rerender = false
})
}
},
mounted () {
window.addEventListener('orientationchange', this.onOrientationChange)
},
beforeUnmount () {
window.removeEventListener('orientationchange', this.onOrientationChange)
}
}
</script>