forked from PanJiaChen/vue-element-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit ab1922e Author: 花裤衩 <panfree23@gmail.com> Date: Fri May 24 10:02:27 2019 +0800 Create FUNDING.yml commit 13c1ecf Author: 花裤衩 <panfree23@gmail.com> Date: Thu May 23 11:27:10 2019 +0800 fix[Chart]: fixed chart bug in keep-alive (PanJiaChen#2119)
- Loading branch information
Edwin Hui
committed
May 24, 2019
1 parent
43e8e8f
commit 684092f
Showing
6 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
patreon: panjiachen | ||
custom: https://panjiachen.github.io/vue-element-admin-site/donate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { debounce } from '@/utils' | ||
|
||
export default { | ||
data() { | ||
return { | ||
$_sidebarElm: null | ||
} | ||
}, | ||
mounted() { | ||
this.$_initResizeEvent() | ||
this.$_initSidebarResizeEvent() | ||
}, | ||
beforeDestroy() { | ||
this.$_destroyResizeEvent() | ||
this.$_destroySidebarResizeEvent() | ||
}, | ||
// to fixed bug when cached by keep-alive | ||
// https://github.com/PanJiaChen/vue-element-admin/issues/2116 | ||
activated() { | ||
this.$_initResizeEvent() | ||
this.$_initSidebarResizeEvent() | ||
}, | ||
deactivated() { | ||
this.$_destroyResizeEvent() | ||
this.$_destroySidebarResizeEvent() | ||
}, | ||
methods: { | ||
// use $_ for mixins properties | ||
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential | ||
$_resizeHandler() { | ||
return debounce(() => { | ||
if (this.chart) { | ||
this.chart.resize() | ||
} | ||
}, 100)() | ||
}, | ||
$_initResizeEvent() { | ||
window.addEventListener('resize', this.$_resizeHandler) | ||
}, | ||
$_destroyResizeEvent() { | ||
window.removeEventListener('resize', this.$_resizeHandler) | ||
}, | ||
$_sidebarResizeHandler(e) { | ||
if (e.propertyName === 'width') { | ||
this.$_resizeHandler() | ||
} | ||
}, | ||
$_initSidebarResizeEvent() { | ||
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0] | ||
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler) | ||
}, | ||
$_destroySidebarResizeEvent() { | ||
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler) | ||
} | ||
} | ||
} |