mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat(overview): stop scroll of the sidebar when the bottom is reached
This commit is contained in:
parent
461b268661
commit
788f733c96
1 changed files with 46 additions and 4 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="overviewLoaded" key="overview" class="mt-3 flex text-center">
|
<div v-if="overviewLoaded" key="overview" class="mt-3 relative flex items-start text-center">
|
||||||
<div class="w-3/12">
|
<div ref="sidebar" :class="{'fixed fixed-sidebar': fixedSidebar}" class="sidebar">
|
||||||
<SummonerChampions />
|
<SummonerChampions />
|
||||||
<SummonerStats />
|
<SummonerStats />
|
||||||
<SummonerMates />
|
<SummonerMates />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-9/12">
|
<div :class="{'pushed-container': fixedSidebar}" class="w-9/12">
|
||||||
<div v-if="current && current.participants" class="mb-4">
|
<div v-if="current && current.participants" class="mb-4">
|
||||||
<LiveMatch />
|
<LiveMatch />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -54,6 +54,16 @@ export default {
|
||||||
SummonerStats,
|
SummonerStats,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
fixedSidebar: false,
|
||||||
|
sidebarRectangle: {
|
||||||
|
y: 354,
|
||||||
|
height: null,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
current: state => state.summoner.live.match,
|
current: state => state.summoner.live.match,
|
||||||
|
|
@ -64,7 +74,7 @@ export default {
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
overviewLoaded() {
|
overviewLoaded() {
|
||||||
this.fetchData()
|
this.getSidebarHeight()
|
||||||
},
|
},
|
||||||
summonerFound() {
|
summonerFound() {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
|
|
@ -73,6 +83,15 @@ export default {
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
|
window.addEventListener('scroll', this.handleScroll)
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.getSidebarHeight()
|
||||||
|
},
|
||||||
|
|
||||||
|
destroyed() {
|
||||||
|
window.removeEventListener('scroll', this.handleScroll)
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -81,7 +100,30 @@ export default {
|
||||||
this.overviewRequest()
|
this.overviewRequest()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getSidebarHeight() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.sidebarRectangle.height = this.$refs.sidebar ? this.$refs.sidebar.getBoundingClientRect().height : null
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleScroll() {
|
||||||
|
if (!this.sidebarRectangle.height) return
|
||||||
|
this.fixedSidebar = window.innerHeight + document.documentElement.scrollTop > this.sidebarRectangle.y + this.sidebarRectangle.height + 112
|
||||||
|
},
|
||||||
...mapActions('summoner', ['moreMatches', 'overviewRequest']),
|
...mapActions('summoner', ['moreMatches', 'overviewRequest']),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.sidebar {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-sidebar {
|
||||||
|
bottom: 112px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pushed-container {
|
||||||
|
margin-left: 300px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue