mizzkey/src/client/app/desktop/views/pages/deck/deck.column.vue

92 lines
1.6 KiB
Vue
Raw Normal View History

2018-06-05 14:36:21 +02:00
<template>
<div class="dnpfarvgbnfmyzbdquhhzyxcmstpdqzs">
2018-06-05 18:54:24 +02:00
<header :class="{ indicate }">
2018-06-05 15:54:03 +02:00
<slot name="header"></slot>
2018-06-05 14:36:21 +02:00
</header>
<div ref="body">
2018-06-05 15:54:03 +02:00
<slot></slot>
2018-06-05 14:36:21 +02:00
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
2018-06-05 18:54:24 +02:00
data() {
return {
indicate: false
};
2018-06-05 14:36:21 +02:00
},
2018-06-05 18:54:24 +02:00
2018-06-05 15:54:03 +02:00
provide() {
return {
2018-06-05 18:54:24 +02:00
column: this,
isScrollTop: this.isScrollTop,
indicate: v => this.indicate = v
2018-06-05 15:54:03 +02:00
};
},
2018-06-05 18:54:24 +02:00
2018-06-05 14:36:21 +02:00
mounted() {
2018-06-05 18:54:24 +02:00
this.$refs.body.addEventListener('scroll', this.onScroll);
},
beforeDestroy() {
this.$refs.body.removeEventListener('scroll', this.onScroll);
},
methods: {
isScrollTop() {
return this.$refs.body.scrollTop == 0;
},
onScroll() {
if (this.isScrollTop()) {
this.$emit('top');
}
2018-06-05 15:54:03 +02:00
2018-06-05 18:54:24 +02:00
if (this.$store.state.settings.fetchOnScroll !== false) {
const current = this.$refs.body.scrollTop + this.$refs.body.clientHeight;
if (current > this.$refs.body.scrollHeight - 1) this.$emit('bottom');
}
}
2018-06-05 14:36:21 +02:00
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
root(isDark)
flex 1
2018-06-05 14:44:02 +02:00
min-width 330px
2018-06-05 15:54:03 +02:00
max-width 330px
2018-06-05 14:36:21 +02:00
height 100%
background isDark ? #282C37 : #fff
border-radius 6px
box-shadow 0 2px 16px rgba(#000, 0.1)
overflow hidden
> header
z-index 1
2018-06-05 15:54:03 +02:00
line-height 42px
2018-06-05 14:36:21 +02:00
padding 0 16px
color isDark ? #e3e5e8 : #888
background isDark ? #313543 : #fff
box-shadow 0 1px rgba(#000, 0.15)
2018-06-05 18:54:24 +02:00
&.indicate
box-shadow 0 3px 0 0 $theme-color
2018-06-05 14:36:21 +02:00
> div
2018-06-05 15:54:03 +02:00
height calc(100% - 42px)
2018-06-05 14:36:21 +02:00
overflow auto
2018-06-05 14:44:02 +02:00
overflow-x hidden
2018-06-05 14:36:21 +02:00
.dnpfarvgbnfmyzbdquhhzyxcmstpdqzs[data-darkmode]
root(true)
.dnpfarvgbnfmyzbdquhhzyxcmstpdqzs:not([data-darkmode])
root(false)
</style>