Skip to content

Commit bc3d4a4

Browse files
committed
格式化代码,解决双指滚动bug
1 parent 5f64322 commit bc3d4a4

17 files changed

+337
-316
lines changed

harmony/smart_refresh_layout.har

225 Bytes
Binary file not shown.

harmony/smart_refresh_layout/src/main/ets/PullToRefresh.ets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ export struct PullToRefresh {
150150
})
151151
.onActionUpdate((event?: GestureEvent) => {
152152
if (event !== undefined) {
153+
if (event.fingerList.length !== 1){
154+
this.touchYOld = event.offsetY;
155+
}
153156
this.onActionUpdate(event);
154157
}
155158
})

harmony/smart_refresh_layout/src/main/ets/RNCAnyHeader.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from 'rnoh'
2424
import Logger from './Logger'
2525

26-
const TAG: string = "[RNOH] SmartRefreshLayout"
26+
const TAG: string = "[RNOH] RNCAnyHeader"
2727
export const ANY_HEADER_TYPE = "RNCAnyHeader"
2828

2929
export interface AnyHeaderProps extends ViewBaseProps {

harmony/smart_refresh_layout/src/main/ets/RNCDefaultHeader.ets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from 'rnoh'
2424
import Logger from './Logger'
2525

26-
const TAG: string = "[RNOH] SmartRefreshLayout"
26+
const TAG: string = "[RNOH] RNCDefaultHeader"
2727
export const DEFAULT_HEADER_TYPE = "RNCDefaultHeader"
2828

2929
export interface DefaultHeaderProps extends ViewBaseProps {
@@ -42,7 +42,7 @@ export struct RNCDefaultHeader {
4242

4343
aboutToAppear() {
4444
this.descriptor = this.ctx.descriptorRegistry.getDescriptor<DefaultHeaderDescriptor>(this.tag)
45-
Logger.info(TAG," RNCDefaultHeader: props = " + JSON.stringify(this.descriptor.props))
45+
Logger.info(TAG,"RNCDefaultHeader: props = " + JSON.stringify(this.descriptor.props))
4646
this.unregisterDescriptorChangesListener = this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
4747
(newDescriptor) => {
4848
this.descriptor = (newDescriptor as DefaultHeaderDescriptor)

harmony/smart_refresh_layout/src/main/ets/SmartRefreshControl.ets

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
Tag,
2323
ColorSegments,
2424
convertColorSegmentsToString,
25-
RNScrollViewManager
25+
RNScrollViewManager,
2626
} from 'rnoh'
2727
import { PullToRefresh } from './PullToRefresh'
2828
import { PullToRefreshConfigurator } from './PullToRefreshConfigurator'
@@ -58,6 +58,7 @@ export struct SmartRefreshControl {
5858
@State descriptor: SmartRefreshControlDescriptor = {} as SmartRefreshControlDescriptor
5959
private unregisterDescriptorChangesListener?: () => void = undefined
6060
private cleanupCommandCallback?: () => void = undefined
61+
private unlockScrollingCallback?: () => void = undefined
6162
private scroller: Scroller = new Scroller();
6263
private pullToRefreshConfigurator:PullToRefreshConfigurator = new PullToRefreshConfigurator();
6364
private finishRefresh:(value: string | PromiseLike<string>) => void = ()=>{}
@@ -168,6 +169,14 @@ export struct SmartRefreshControl {
168169
}
169170

170171
checkHeaderMove(displayedHeaderHeight:number){
172+
if (this.unlockScrollingCallback === undefined && displayedHeaderHeight != 0){
173+
this.getScroller().scrollEdge(Edge.Top)
174+
this.unlockScrollingCallback = this.getChildScrollViewComponentManager()?.lockScrolling()
175+
}
176+
if (this.unlockScrollingCallback !== undefined && displayedHeaderHeight == 0){
177+
this.unlockScrollingCallback()
178+
this.unlockScrollingCallback = undefined
179+
}
171180
// 下拉中
172181
if (this.displayedHeaderHeight < displayedHeaderHeight) {
173182
this.onHeaderPulling(displayedHeaderHeight)
@@ -177,8 +186,14 @@ export struct SmartRefreshControl {
177186
this.displayedHeaderHeight = displayedHeaderHeight
178187
}
179188

189+
// 因为子节点还没创建出来,需要延迟获取RNScrollViewManager
190+
getChildScrollViewComponentManager():RNScrollViewManager{
191+
let scrollViewComponentManager = this.ctx.componentManagerRegistry.getComponentManager(this.scrollViewTag) as RNScrollViewManager
192+
return scrollViewComponentManager
193+
}
194+
180195
getScroller():Scroller{
181-
let scroller = (this.ctx.componentManagerRegistry.getComponentManager(this.scrollViewTag) as RNScrollViewManager).getScroller() as Scroller
196+
let scroller = this.getChildScrollViewComponentManager()?.getScroller() as Scroller
182197
if (scroller) {
183198
return scroller
184199
}else {

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-native-smartrefreshlayout",
3-
"version": "0.6.7-0.0.8",
2+
"name": "@react-native-oh-tpl/react-native-smartrefreshlayout",
3+
"version": "0.6.7-0.0.9",
44
"description": "基于android SmartRefreshLayout的封装",
55
"main": "lib/commonjs/index.js",
66
"react-native": "src/index.tsx",
@@ -9,11 +9,16 @@
99
"types": "lib/typescript/src/index.d.ts",
1010
"scripts": {
1111
"test": "npm test",
12-
"prepare": "bob build"
12+
"prepare": "bob build",
13+
"prettier": "prettier --write src"
14+
},
15+
"publishConfig": {
16+
"registry": "https://registry.npmjs.org/",
17+
"access": "public"
1318
},
1419
"repository": {
1520
"type": "git",
16-
"url": "git+https://github.com/react-native-studio/react-native-SmartRefreshLayout.git"
21+
"url": "https://github.com/react-native-oh-library/react-native-SmartRefreshLayout.git"
1722
},
1823
"keywords": [
1924
"react",

src/AnyHeader.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import RCTAnyHeader,{NativeProps as AnyHeaderProps} from './fabric/AnyHeaderNativeComponent';
2-
import React from 'react';
1+
import RCTAnyHeader, {
2+
NativeProps as AnyHeaderProps,
3+
} from "./fabric/AnyHeaderNativeComponent";
4+
import React from "react";
35

46
export class AnyHeader extends React.Component<AnyHeaderProps> {
5-
6-
render() {
7-
return (
8-
<RCTAnyHeader
9-
{...this.props}
10-
style={{height:0}}
11-
>
12-
{this.props.children}
13-
</RCTAnyHeader>
14-
)
15-
}
7+
render() {
8+
return (
9+
<RCTAnyHeader {...this.props} style={{ height: 0 }}>
10+
{this.props.children}
11+
</RCTAnyHeader>
12+
);
13+
}
1614
}
1715

18-
export default AnyHeader;
16+
export default AnyHeader;

0 commit comments

Comments
 (0)