提交 abd9cb68 编写于 作者: zhujiamin's avatar zhujiamin

回到顶部按钮及动画

上级 6f97e714
...@@ -169,6 +169,7 @@ ...@@ -169,6 +169,7 @@
</ion-list> </ion-list>
</#if> </#if>
<div class="no-data" v-if="items.length == 0">暂无数据</div> <div class="no-data" v-if="items.length == 0">暂无数据</div>
<div class="scrollToTop" @click="scrollToTop" ref="scroll"> <van-icon name="back-top" /></div>
</div> </div>
</div> </div>
</template> </template>
\ No newline at end of file
...@@ -876,12 +876,19 @@ ...@@ -876,12 +876,19 @@
* *
* @memberof ${srfclassname('${ctrl.codeName}')} * @memberof ${srfclassname('${ctrl.codeName}')}
*/ */
/**
public mounted(){ public mounted(){
let list:any = this.$refs.mdctrl; let list:any = this.$refs.mdctrl;
let scroll:any = this.$refs.scroll;
if(list){ if(list){
list.addEventListener('touchend',()=>{ list.addEventListener('touchend',()=>{
this.$store.commit('setPopupStatus',true) this.$store.commit('setPopupStatus',true)
}) }, false)
list.addEventListener('scroll', (e:any) => {
if (scroll && list) {
scroll.style.opacity = list.scrollTop * 0.001;
}
}, false)
} }
} }
...@@ -1095,6 +1102,27 @@ ...@@ -1095,6 +1102,27 @@
}) })
} }
/**
* 滑回顶部
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public scrollToTop(){
let mdctrl:any = this.$refs.mdctrl;
if (mdctrl) {
requestAnimationFrame(function () {
let top:number = mdctrl.scrollTop;
let speed:number = top / 6;
if (top!= 0) {
mdctrl.scrollTop -= speed;
}
});
if (mdctrl.scrollTop != 0) {
requestAnimationFrame(this.scrollToTop);
}
}
}
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude> </#ibizinclude>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
} }
.app-mob-mdctrl{ .app-mob-mdctrl{
height:100%; height:100%;
overflow: auto;
.app-mob-mdctrl-${ctrl.name}{ .app-mob-mdctrl-${ctrl.name}{
height:100%; height:100%;
.items{ .items{
...@@ -78,6 +79,23 @@ ...@@ -78,6 +79,23 @@
margin-top:0; margin-top:0;
} }
} }
.scrollToTop{
opacity: 0;
position: absolute;
right: 20px;
bottom: 120px;
width: 30px;
height: 30px;
border-radius: 50%;
line-height: 40px;
text-align: center;
background-color: #fff;
box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.2);
.van-icon{
font-size: 20px;
color: #333;
}
}
} }
} }
<#if appde??> <#if appde??>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册