File tree 3 files changed +33
-35
lines changed
packages/core/ui/scroll-view
3 files changed +33
-35
lines changed Original file line number Diff line number Diff line change @@ -130,10 +130,10 @@ export class ScrollView extends ScrollViewBase {
130
130
131
131
protected attachNative ( ) {
132
132
if ( ! this . handler ) {
133
- const that = new WeakRef ( this ) ;
133
+ const viewRef = new WeakRef ( this ) ;
134
134
this . handler = new android . view . ViewTreeObserver . OnScrollChangedListener ( {
135
135
onScrollChanged : function ( ) {
136
- const owner : ScrollView = that . get ( ) ;
136
+ const owner : ScrollView = viewRef . get ( ) ;
137
137
if ( owner ) {
138
138
owner . _onScrollChanged ( ) ;
139
139
}
@@ -166,9 +166,13 @@ export class ScrollView extends ScrollViewBase {
166
166
}
167
167
}
168
168
169
- protected dettachNative ( ) {
170
- this . nativeViewProtected . getViewTreeObserver ( ) . removeOnScrollChangedListener ( this . handler ) ;
171
- this . handler = null ;
169
+ protected detachNative ( ) {
170
+ if ( this . handler ) {
171
+ if ( this . nativeViewProtected ) {
172
+ this . nativeViewProtected . getViewTreeObserver ( ) . removeOnScrollChangedListener ( this . handler ) ;
173
+ }
174
+ this . handler = null ;
175
+ }
172
176
}
173
177
}
174
178
Original file line number Diff line number Diff line change @@ -49,12 +49,6 @@ export class ScrollView extends ScrollViewBase {
49
49
this . _setNativeClipToBounds ( ) ;
50
50
}
51
51
52
- disposeNativeView ( ) {
53
- this . dettachNative ( ) ;
54
- this . _delegate = null ;
55
- super . disposeNativeView ( ) ;
56
- }
57
-
58
52
_setNativeClipToBounds ( ) {
59
53
if ( ! this . nativeViewProtected ) {
60
54
return ;
@@ -70,9 +64,12 @@ export class ScrollView extends ScrollViewBase {
70
64
}
71
65
}
72
66
73
- protected dettachNative ( ) {
74
- if ( this . nativeViewProtected ) {
75
- this . nativeViewProtected . delegate = null ;
67
+ protected detachNative ( ) {
68
+ if ( this . _delegate ) {
69
+ if ( this . nativeViewProtected ) {
70
+ this . nativeViewProtected . delegate = null ;
71
+ }
72
+ this . _delegate = null ;
76
73
}
77
74
}
78
75
Original file line number Diff line number Diff line change @@ -21,48 +21,45 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe
21
21
22
22
if ( arg === ScrollViewBase . scrollEvent ) {
23
23
this . _scrollChangeCount ++ ;
24
- this . attach ( ) ;
24
+ if ( this . nativeViewProtected ) {
25
+ this . attachNative ( ) ;
26
+ }
25
27
}
26
28
}
27
29
28
30
public removeEventListener ( arg : string , callback ?: ( data : EventData ) => void , thisArg ?: any ) : void {
29
31
super . removeEventListener ( arg , callback , thisArg ) ;
30
32
31
33
if ( arg === ScrollViewBase . scrollEvent ) {
32
- this . _scrollChangeCount -- ;
33
- this . dettach ( ) ;
34
- }
35
- }
36
-
37
- @profile
38
- public onLoaded ( ) {
39
- super . onLoaded ( ) ;
40
-
41
- this . attach ( ) ;
42
- }
34
+ if ( this . _scrollChangeCount > 0 ) {
35
+ this . _scrollChangeCount -- ;
43
36
44
- public disposeNativeView ( ) {
45
- this . dettach ( ) ;
46
- super . disposeNativeView ( ) ;
37
+ if ( this . nativeViewProtected && this . _scrollChangeCount === 0 ) {
38
+ this . detachNative ( ) ;
39
+ }
40
+ }
41
+ }
47
42
}
48
43
49
- private attach ( ) {
50
- if ( this . _scrollChangeCount > 0 && this . isLoaded ) {
44
+ initNativeView ( ) {
45
+ super . initNativeView ( ) ;
46
+ if ( this . _scrollChangeCount > 0 ) {
51
47
this . attachNative ( ) ;
52
48
}
53
49
}
54
50
55
- private dettach ( ) {
56
- if ( this . _scrollChangeCount === 0 && this . isLoaded ) {
57
- this . dettachNative ( ) ;
51
+ public disposeNativeView ( ) {
52
+ if ( this . _scrollChangeCount > 0 ) {
53
+ this . detachNative ( ) ;
58
54
}
55
+ super . disposeNativeView ( ) ;
59
56
}
60
57
61
58
protected attachNative ( ) {
62
59
//
63
60
}
64
61
65
- protected dettachNative ( ) {
62
+ protected detachNative ( ) {
66
63
//
67
64
}
68
65
You can’t perform that action at this time.
0 commit comments