Merge pull request #81 from jingsam/simplify-backtop

simpilfy back-top.vue
This commit is contained in:
Aresn 2016-11-15 09:34:21 +08:00 committed by GitHub
commit eaaea36a03
2 changed files with 5 additions and 25 deletions

View file

@ -10,19 +10,6 @@
<script>
const prefixCls = 'ivu-back-top';
function getScroll(target, top) {
const prop = top ? 'pageYOffset' : 'pageXOffset';
const method = top ? 'scrollTop' : 'scrollLeft';
let ret = target[prop];
if (typeof ret !== 'number') {
ret = window.document.documentElement[method];
}
return ret;
}
export default {
props: {
height: {
@ -72,14 +59,7 @@
},
methods: {
handleScroll () {
const backTop = this.backTop;
const scrollTop = getScroll(window, true);
if (this.height <= scrollTop && !backTop) {
this.backTop = true;
} else if (this.height > scrollTop && backTop) {
this.backTop = false;
}
this.backTop = window.pageYOffset >= this.height;
},
back () {
window.scrollTo(0, 0);
@ -87,4 +67,4 @@
}
}
}
</script>
</script>

View file

@ -50,9 +50,9 @@
<div @click="spinShow = !spinShow">消失</div>
<br><br>
<Button @click="nextStep">下一步</Button>
<Button @click="step_status = 'error'">步骤3切换为错误</Button>
<Button @click="step_process = 'error'">切换steps状态为error</Button>
<i-button @click="nextStep">下一步</i-button>
<i-button @click="step_status = 'error'">步骤3切换为错误</i-button>
<i-button @click="step_process = 'error'">切换steps状态为error</i-button>
<Breadcrumb separator="<b>=></b>">
<Breadcrumb-item href="/index">首页</Breadcrumb-item>
<Breadcrumb-item href="/my">我的</Breadcrumb-item>