Skip to content

Commit

Permalink
iOS: fix non ui thread access view content offset
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpeng authored and penfeizhou committed Jul 20, 2023
1 parent 01b30f4 commit 761a6f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
13 changes: 7 additions & 6 deletions doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}

NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};

__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}
Expand Down
13 changes: 7 additions & 6 deletions doric-iOS/Pod/Classes/Shader/DoricHorizontalListNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}

NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};

__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}
Expand Down
13 changes: 7 additions & 6 deletions doric-iOS/Pod/Classes/Shader/DoricListNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}

NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};

__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}
Expand Down
13 changes: 7 additions & 6 deletions doric-iOS/Pod/Classes/Shader/DoricScrollerNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}

NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};

__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}
Expand Down

0 comments on commit 761a6f6

Please sign in to comment.