Skip to content

Commit

Permalink
Charts: Force re-render on device orientation change (#2706)
Browse files Browse the repository at this point in the history
Fixes #2702.

Signed-off-by: Florian Hotze <[email protected]>
(cherry picked from commit f7f04bf)
  • Loading branch information
florian-h05 committed Aug 12, 2024
1 parent 0aae365 commit 668538e
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;'"
Expand Down Expand Up @@ -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>

0 comments on commit 668538e

Please sign in to comment.