Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
5a574ce3
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5a574ce3
编写于
11月 29, 2023
作者:
DCloud-yyl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新半屏弹出示例
上级
d55b8d7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
26 deletion
+33
-26
pages/tabBar/template.uvue
pages/tabBar/template.uvue
+8
-9
pages/template/half-screen/half-screen.uvue
pages/template/half-screen/half-screen.uvue
+25
-17
未找到文件。
pages/tabBar/template.uvue
浏览文件 @
5a574ce3
...
...
@@ -130,14 +130,13 @@
open: false,
pages: [] as Page[],
},
// {
// id: 'half-screen',
// url: 'half-screen',
// name: '半屏弹窗',
// open: false,
// enable: false,
// pages: [] as Page[],
// },
{
id: 'half-screen',
url: 'half-screen',
name: '半屏弹窗',
open: false,
pages: [] as Page[],
},
{
id: 'drop-card',
url: 'drop-card',
...
...
@@ -226,4 +225,4 @@
<style>
@import '../../common/uni-uvue.css';
</style>
\ No newline at end of file
</style>
pages/template/half-screen/half-screen.uvue
浏览文件 @
5a574ce3
<template>
<view class="page">
<view
id="page"
class="page">
<text>TouchEvent还有细节需要优化,需支持拦截事件分发逻辑解决拖拽半屏窗口引起内容滚动的问题</text>
<button class="bottomButton" @click="switchHalfScreen(true)">打开弹窗</button>
<view
ref
="halfScreen" class="halfScreen" @touchstart="onHalfTouchStart" @touchmove="onHalfTouchMove" @touchend="onHalfTouchEnd">
<view
id
="halfScreen" class="halfScreen" @touchstart="onHalfTouchStart" @touchmove="onHalfTouchMove" @touchend="onHalfTouchEnd">
<view class="halfTitle" >半屏弹窗标题</view>
<scroll-view
ref="halfScroll" class="halfScroll" @scroll="onScroll" bounce
="true">
<scroll-view
id="halfScroll" class="halfScroll" @scroll="onScroll" rebound
="true">
<view v-for="(item,index) in list" :key="index" class="item">
half screen content-{{item}}
</view>
...
...
@@ -48,22 +48,32 @@
this.halfScreenY = p.screenY;
}
let offset = p.screenY-this.halfScreenY;
if(offset > 0){
if(offset > 0){
//向下滚动
this.halfMove = true;
this.scrollNode?.setAttribute('scroll-y', 'false');
this.halfNode?.style?.setProperty('transform','translateY('+offset+'px)');
if(offset==0){
console.log('translateY(0px)', this.halfOffset)
}
this.halfOffset = offset;
}else if(this.
lastY2>this.lastY && this.halfOffset>0){//容错触发向下滚动的误差
}else if(this.
halfOffset>0){//向上滚动
offset = this.halfScreenY-p.screenY;
if(offset>this.halfOffset){
offset = this.halfOffset;
offset = 0;
this.halfMove = false;
this.scrollNode?.setAttribute('scroll-y', 'true');
}
this.halfNode?.style?.setProperty('transform','translateY('+offset+'px)');
if(offset==0){
console.log('translateY(0px)', this.halfOffset)
}
this.halfOffset = offset;
}
}
//console.log('TouchMove', e.target);
},
onHalfTouchEnd(_:TouchEvent) {
this.halfScreenY = 0;
if(this.bAnimation){//容错处理
return;
}
...
...
@@ -76,7 +86,7 @@
}
if(bHide){
this.switchHalfScreen(false);
}else{
}else
if(this.halfOffset>0)
{
this.resumeHalfScreen();
}
},
...
...
@@ -89,6 +99,7 @@
return;
}
this.halfMove = false;
this.scrollNode?.setAttribute('scroll-y', 'true');
this.halfScreenY = 0;
this.halfOffset = 0;
let top = this.totalHeight;
...
...
@@ -103,7 +114,7 @@
}
this.halfNode?.style?.setProperty('transitionDuration', time.toFixed(0));
this.halfNode?.style?.setProperty('transitionProperty','top');
this.halfNode?.style?.setProperty('top', top.toFixed(
0
));
this.halfNode?.style?.setProperty('top', top.toFixed(
2
));
setTimeout(()=>{
if(!show){
this.halfNode?.style?.setProperty('visibility','hidden');
...
...
@@ -122,6 +133,7 @@
this.halfNode?.style?.setProperty('transitionProperty','transform');
this.halfNode?.style?.setProperty('transform','translateY(0px)');
this.halfMove = false;
this.scrollNode?.setAttribute('scroll-y', 'true');
this.halfScreenY = 0;
this.halfOffset = 0;
setTimeout(()=>{
...
...
@@ -131,17 +143,13 @@
}
},
onReady() {
this.halfNode =
this.$refs['halfScreen'] as Element
;
this.halfNode =
uni.getElementById('halfScreen')
;
this.halfHeight = this.halfNode!.getBoundingClientRect().height;
this.scrollNode =
this.$refs['halfScroll'] as Element
;
this.scrollNode =
uni.getElementById('halfScroll')
;
this.totalHeight = uni.getWindowInfo().windowHeight;
this.totalHeight = uni.get
ElementById('page')?.getBoundingClientRect()?.height??0;//uni.get
WindowInfo().windowHeight;
this.halfNode?.style?.setProperty('top', this.totalHeight.toString());
},
// onResize() {
// this.halfHeight = this.halfNode!.getBoundingClientRect().height;
// this.totalHeight = uni.getWindowInfo().windowHeight;
// }
}
</script>
...
...
@@ -169,11 +177,11 @@
align-items: center;
justify-content: center;
height: 48px;
background-color:
cornflowerblu
e;
background-color:
ghostwhit
e;
border-radius: 10px 10px 0 0;
}
.halfScroll {
background-color:
ghost
white;
background-color: white;
}
.item {
height: 100px;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录