yangchenggong1_wd

fix |> 20602 【生产环境】【第三次内部验收】直播频道横滑卡,左滑时,松手跳转手势-查看更多发生抖动;

@@ -23,93 +23,20 @@ export struct LiveHorizontalCardComponent { @@ -23,93 +23,20 @@ export struct LiveHorizontalCardComponent {
23 @State moreTips: string = '' 23 @State moreTips: string = ''
24 scroller: Scroller = new Scroller() 24 scroller: Scroller = new Scroller()
25 @State compIndex: number = 0; 25 @State compIndex: number = 0;
  26 + @State ellipseW: number = 0
  27 + @State isEnd: boolean = false
  28 + @State listLeft: number = 0
26 29
27 - resetMoreTips() {  
28 - console.log('resetMoreTips', this.moreWidth, this.initMoreWidth)  
29 - if (this.moreWidth < this.initMoreWidth * 2) {  
30 - this.moreTips = '查看更多';  
31 - }  
32 - }  
33 -  
34 - edgeAnimation() {  
35 - if (this.moreWidth < this.initMoreWidth * 3) {  
36 - if (!this.moreTips) {  
37 - this.moreTips = '查看更多';  
38 - }  
39 - this.moreWidth = this.moreWidth + 2  
40 - }  
41 - if (this.moreWidth > this.initMoreWidth * 2) {  
42 - this.moreTips = '松手查看';  
43 - } else {  
44 -  
45 - }  
46 - }  
47 -  
48 - reverseEdgeAnimation() {  
49 - if (this.moreWidth > this.initMoreWidth) {  
50 - this.moreWidth = this.moreWidth - 2  
51 - }  
52 - this.resetMoreTips()  
53 - }  
54 -  
55 - resetEdgeAnimation() {  
56 - if (this.moreWidth > this.initMoreWidth) {  
57 - this.moreWidth = 22  
58 - }  
59 - this.resetMoreTips()  
60 - }  
61 -  
62 - toMore() {  
63 - if (this.moreWidth > this.initMoreWidth * 2) {  
64 - this.liveToMore();  
65 - }  
66 - }  
67 30
68 liveToMore() { 31 liveToMore() {
69 ProcessUtils.compJumpPage(this.compDTO) 32 ProcessUtils.compJumpPage(this.compDTO)
70 return; 33 return;
71 - if (!!this.compDTO.dataSourceType) {  
72 - if (this.compDTO.linkUrl) {  
73 - let taskAction: Action = {  
74 - type: 'JUMP_INNER_NEW_PAGE',  
75 - params: {  
76 - url: this.compDTO.linkUrl,  
77 - pageID: 'SPACIAL_TOPIC_PAGE',  
78 - contentID: this.compDTO.objectId,  
79 - extra: {  
80 - relId: this.compDTO.relId,  
81 - relType: this.compDTO.relType,  
82 - pageId: this.compDTO.pageId  
83 - }  
84 - } as Params,  
85 - };  
86 - WDRouterRule.jumpWithAction(taskAction)  
87 - } else {  
88 - this.jumpToLiveMorePage()  
89 - }  
90 - } else {  
91 - if (this.compDTO?.objectType === '11') {  
92 - } else {  
93 - const contentDTO: ContentDTO = {  
94 - objectId: this.compDTO.objectId,  
95 - objectType: this.compDTO.objectType,  
96 - linkUrl: this.compDTO.linkUrl,  
97 - pageId: this.compDTO.pageId  
98 - } as ContentDTO  
99 - ProcessUtils.processPage(contentDTO)  
100 - }  
101 - }  
102 -}  
103 -  
104 - async aboutToAppear(): Promise<void> {  
105 - // this.loadImg = await onlyWifiLoadImg();  
106 } 34 }
107 35
108 showMore() { 36 showMore() {
109 return (!!this.compDTO.dataSourceType && this.compDTO.dataSourceType !== 'OBJECT_POS') || !(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '') 37 return (!!this.compDTO.dataSourceType && this.compDTO.dataSourceType !== 'OBJECT_POS') || !(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '')
110 } 38 }
111 39
112 -  
113 build() { 40 build() {
114 Column() { 41 Column() {
115 Row() { 42 Row() {
@@ -193,31 +120,30 @@ export struct LiveHorizontalCardComponent { @@ -193,31 +120,30 @@ export struct LiveHorizontalCardComponent {
193 } 120 }
194 }) 121 })
195 }) 122 })
196 - } 123 + }.offset({ left: this.listLeft })
  124 +
197 if (this.compDTO.operDataList.length >= 2 && this.showMore()) { 125 if (this.compDTO.operDataList.length >= 2 && this.showMore()) {
198 Row() { 126 Row() {
199 Ellipse() 127 Ellipse()
200 - .width(2* (this.moreWidth - this.initMoreWidth - 1)) 128 + .width(2 * this.ellipseW)
201 .height('100%') 129 .height('100%')
202 - .fill(0xe9e9e9)  
203 - .position({ left: -(this.moreWidth - this.initMoreWidth - 3) * 0.8 , top: 0 }) 130 + .fill('rgb(240,235,238)')
  131 + .position({ left: -this.ellipseW, top: 0 })
204 132
205 Column() { 133 Column() {
206 - if (this.moreWidth > this.initMoreWidth + 2) {  
207 - Text(this.moreTips)  
208 - .fontSize(9)  
209 - .fontColor(0x858585)  
210 - .width(8)  
211 - } 134 + Text(this.ellipseW === 0 ? '' : this.ellipseW < 20 ? '查看更多' : '松手查看')
  135 + .width('19lpx')
  136 + .fontSize('19lpx')
  137 + .fontWeight('400lpx')
  138 + .lineHeight('27lpx')
  139 + .fontColor("#9E9E9E")
212 } 140 }
213 - .justifyContent(FlexAlign.Center)  
214 - .align(Alignment.Center)  
215 .height('100%') 141 .height('100%')
216 - .width(this.initMoreWidth)  
217 - .backgroundColor(0xe9e9e9)  
218 - .borderRadius({ topLeft: 5, bottomLeft: 5 }) 142 + .width(this.moreWidth)
  143 + .backgroundColor("#EDEDED")
  144 + .justifyContent(FlexAlign.Center)
219 } 145 }
220 - .margin({left: 1.5 * (this.moreWidth - this.initMoreWidth)}) 146 + .height('100%')
221 } 147 }
222 } 148 }
223 } 149 }
@@ -226,24 +152,43 @@ export struct LiveHorizontalCardComponent { @@ -226,24 +152,43 @@ export struct LiveHorizontalCardComponent {
226 .scrollBar(BarState.Off) 152 .scrollBar(BarState.Off)
227 .edgeEffect(EdgeEffect.None) 153 .edgeEffect(EdgeEffect.None)
228 .onReachEnd(() => { 154 .onReachEnd(() => {
229 - this.edgeAnimation() 155 + this.isEnd = true
230 }) 156 })
231 - .onScrollStop(() => {  
232 - // this.resetEdgeAnimation();  
233 - })  
234 - .onScroll((xOffset: number, yOffset: number) => {  
235 - if (xOffset < 0) {  
236 - this.reverseEdgeAnimation(); 157 + .onScrollFrameBegin((offset: number, state: ScrollState) => {
  158 + if (!this.scroller.isAtEnd()) {
  159 + this.isEnd = false
237 } 160 }
238 - })  
239 - .onTouch((event?: TouchEvent) => {  
240 - if(event) {  
241 - if (event.type === TouchType.Up) {  
242 - this.toMore();  
243 - this.resetEdgeAnimation();  
244 - } 161 + if (this.ellipseW > 0) {
  162 + return { offsetRemain: 0 }
245 } 163 }
  164 + return { offsetRemain: offset }
246 }) 165 })
  166 + .parallelGesture(
  167 + PanGesture({ direction: PanDirection.Horizontal, distance: 1 })
  168 + .onActionStart((event: GestureEvent) => {
  169 + })
  170 + .onActionUpdate((event: GestureEvent) => {
  171 + if(this.compDTO.operDataList.length >= 2 && this.showMore()){
  172 + if (event && this.isEnd) {
  173 + // console.log('event.offsetX',event.offsetX)
  174 + this.listLeft = event.offsetX < -60 ? -60 : event.offsetX > 0 ? 0 : event.offsetX
  175 + this.ellipseW = (-this.listLeft) / 1.5
  176 + }
  177 + }
  178 +
  179 + })
  180 + .onActionEnd((event: GestureEvent) => {
  181 + if(this.compDTO.operDataList.length >= 2 && this.showMore()){
  182 + this.listLeft = 0
  183 + // this.moreWidth = 20
  184 +
  185 + if (event.offsetX < 0 && this.ellipseW >= 20) {
  186 + this.liveToMore();
  187 + }
  188 + this.ellipseW = 0
  189 + }
  190 + })
  191 + )
247 .width(CommonConstants.FULL_WIDTH) 192 .width(CommonConstants.FULL_WIDTH)
248 .height(this.compDTO.operDataList.length == 2 ? 167 : 134) 193 .height(this.compDTO.operDataList.length == 2 ? 167 : 134)
249 } else if (this.compDTO.operDataList.length) { 194 } else if (this.compDTO.operDataList.length) {