Skip to content

Commit

Permalink
[HOTFIX] Sidebar scroll (#349)
Browse files Browse the repository at this point in the history
Sidebar scroll and computed height were broken whenever the site was opened on a branch or root page.
  • Loading branch information
xbill82 authored and benoitvidis committed Jun 17, 2019
1 parent 102511d commit e254f97
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/.vuepress/theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default {
path: this.$route.path
});
},
onWindowResize() {
computeContentHeight() {
this.setContainerPadding();
setTimeout(() => {
this.computeSidebarHeight();
Expand Down Expand Up @@ -143,10 +143,10 @@ export default {
}
},
mounted() {
if (this.$page.frontmatter.type !== 'page') {
this.$router.replace(getFirstValidChild(this.$page, this.$site.pages));
return;
}
this.$router.afterEach(this.computeContentHeight);
window.addEventListener('resize', this.computeContentHeight.bind(this));
window.addEventListener('scroll', this.computeSidebarHeight.bind(this));
// TODO condition isSupported()
const copy = new Clipboard('.md-clipboard', {
target: trigger => {
Expand All @@ -156,9 +156,11 @@ export default {
copy.on('success', this.onCodeCopied);
window.addEventListener('resize', this.onWindowResize);
window.addEventListener('scroll', this.computeSidebarHeight);
this.onWindowResize();
if (this.$page.frontmatter.type !== 'page') {
this.$router.replace(getFirstValidChild(this.$page, this.$site.pages));
}
this.computeContentHeight();
}
};
</script>
Expand Down

0 comments on commit e254f97

Please sign in to comment.