koel/resources/assets/js/components/shared/to-top-button.vue

74 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<transition name="fade">
<div class="to-top-btn-wrapper" v-show="showing">
<button @click="scrollToTop">
<i class="fa fa-arrow-circle-up"/> Top
</button>
</div>
</transition>
</template>
<script>
import { $ } from '../../utils'
2016-06-25 16:05:24 +00:00
export default {
props: ['el'],
data () {
return {
showing: false
}
},
methods: {
scrollToTop () {
$.scrollTo(this.$el.parentNode, 0, 500, () => {
this.showing = false
})
}
},
mounted () {
this.$el.parentNode.addEventListener('scroll', e => {
this.showing = e.target.scrollTop > 64
})
}
2016-11-26 03:25:35 +00:00
}
</script>
2017-02-14 06:53:02 +00:00
<style lang="scss">
2016-06-25 16:05:24 +00:00
@import "../../../sass/partials/_vars.scss";
@import "../../../sass/partials/_mixins.scss";
.to-top-btn-wrapper {
position: fixed;
width: 100%;
bottom: $footerHeightMobile + 26px;
2016-06-25 16:05:24 +00:00
left: 0;
text-align: center;
2017-01-15 04:15:13 +00:00
z-index: 20;
opacity: 1;
transition: opacity .5s;
2016-06-25 16:05:24 +00:00
&.fade-enter, &.fade-leave-to {
2016-06-25 16:05:24 +00:00
opacity: 0;
}
button {
border-radius: 18px;
padding: 8px 16px;
background: rgba(0, 0, 0, .5);
border: 1px solid $colorMainText;
i {
margin-right: 4px;
}
2016-06-25 16:05:24 +00:00
}
}
@media screen and (min-width: 415px) {
2016-06-25 16:05:24 +00:00
.to-top-btn-wrapper {
display: none;
}
}
</style>