Update for public https://habr.com/post/421887/
This commit is contained in:
18
myapp/static/components/backtotop.css
Normal file
18
myapp/static/components/backtotop.css
Normal file
@@ -0,0 +1,18 @@
|
||||
.scrollToTop{
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
opacity: 0.3;
|
||||
display: inline;
|
||||
}
|
||||
.scrollToTop:hover{
|
||||
text-decoration: none;
|
||||
opacity: 1.0;
|
||||
}
|
||||
.scrollToTop .card{
|
||||
margin-bottom: 0;
|
||||
border-color: #7ca8b1;
|
||||
}
|
||||
53
myapp/static/components/backtotop.js
Normal file
53
myapp/static/components/backtotop.js
Normal file
@@ -0,0 +1,53 @@
|
||||
var backtotopTemplate = `
|
||||
<div>
|
||||
<span class="scrollToTop" style="z-index: 10;" v-show="visible" v-on:click="backToTop">
|
||||
<div class="card">
|
||||
<div class="card-body py-2 px-2">
|
||||
<i class="fa fa-chevron-up"></i>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>`;
|
||||
|
||||
Vue.component('backtotop-component', {
|
||||
props: {
|
||||
visibleoffset: {
|
||||
type: [String, Number],
|
||||
default: 600
|
||||
},
|
||||
},
|
||||
template: backtotopTemplate,
|
||||
data () {
|
||||
return {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
var vm = this;
|
||||
window.addEventListener('scroll', this.catchScroll);
|
||||
let currentScroll = document.documentElement.scrollTop || document.body.scrollTop
|
||||
vm.visible = (currentScroll > 100);
|
||||
},
|
||||
destroyed () {
|
||||
window.removeEventListener('scroll', this.catchScroll)
|
||||
},
|
||||
methods: {
|
||||
catchScroll () {
|
||||
var vm = this;
|
||||
vm.visible = (window.pageYOffset > 100);
|
||||
},
|
||||
backToTop () {
|
||||
var vm = this;
|
||||
vm.scrollAnimate();
|
||||
},
|
||||
scrollAnimate: function() {
|
||||
var vm = this;
|
||||
let currentScroll = document.documentElement.scrollTop || document.body.scrollTop
|
||||
if (currentScroll > 0) {
|
||||
//alert(currentScroll);
|
||||
window.requestAnimationFrame(vm.scrollAnimate)
|
||||
window.scrollTo(0, Math.floor(currentScroll - (currentScroll / 5)))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
8899
myapp/static/css/bootstrap.css
vendored
8899
myapp/static/css/bootstrap.css
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
7
myapp/static/css/bootstrap.min.css
vendored
Normal file
7
myapp/static/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2337
myapp/static/css/font-awesome.css
vendored
2337
myapp/static/css/font-awesome.css
vendored
File diff suppressed because it is too large
Load Diff
4
myapp/static/css/font-awesome.min.css
vendored
Normal file
4
myapp/static/css/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
9
myapp/static/js/axios.min.js
vendored
Normal file
9
myapp/static/js/axios.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3892
myapp/static/js/bootstrap.js
vendored
3892
myapp/static/js/bootstrap.js
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
7
myapp/static/js/bootstrap.min.js
vendored
Normal file
7
myapp/static/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10253
myapp/static/js/jquery-3.2.1.js
vendored
10253
myapp/static/js/jquery-3.2.1.js
vendored
File diff suppressed because it is too large
Load Diff
2
myapp/static/js/jquery-3.3.1.slim.min.js
vendored
Normal file
2
myapp/static/js/jquery-3.3.1.slim.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
5
myapp/static/js/popper.min.js
vendored
Normal file
5
myapp/static/js/popper.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
myapp/static/js/vue.min.js
vendored
Normal file
6
myapp/static/js/vue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user