Skip to content

Commit 3d7bf11

Browse files
committed
fix(ios): missing scrollEnd event
1 parent eeb8b3b commit 3d7bf11

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/collectionview/collectionview.ios.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,11 @@ export class CollectionView extends CollectionViewBase {
903903
}
904904
lastContentOffset: CGPoint;
905905
needsScrollStartEvent = false;
906+
isScrolling = false;
906907
scrollViewWillBeginDragging(scrollView: UIScrollView): void {
907908
this.lastContentOffset = scrollView.contentOffset;
908909
this.needsScrollStartEvent = true;
910+
this.isScrolling = true;
909911
}
910912
scrollViewDidScroll(scrollView: UIScrollView): void {
911913
const contentOffset = scrollView.contentOffset;
@@ -920,15 +922,24 @@ export class CollectionView extends CollectionViewBase {
920922
}
921923
this.notify(this.computeScrollEventData(scrollView, CollectionViewBase.scrollEvent, dx, dy));
922924
}
925+
stopScrolling(scrollView: UIScrollView) {
926+
if (this.isScrolling) {
927+
this.isScrolling = false;
928+
this.notify(this.computeScrollEventData(scrollView, CollectionViewBase.scrollEndEvent));
929+
}
930+
}
923931
scrollViewDidEndDecelerating(scrollView: UIScrollView) {
924-
this.notify(this.computeScrollEventData(scrollView, CollectionViewBase.scrollEndEvent));
932+
this.stopScrolling(scrollView);
925933
}
926934
scrollViewWillEndDraggingWithVelocityTargetContentOffset?(scrollView: UIScrollView, velocity: CGPoint, targetContentOffset: interop.Pointer | interop.Reference<CGPoint>): void {
927-
// this.notify({
928-
// object: this,
929-
// eventName: CollectionViewBase.scrollWillEndEvent,
930-
// scrollOffset: this.isHorizontal() ? scrollView.contentOffset.x : scrollView.contentOffset.y,
931-
// });
935+
this.stopScrolling(scrollView);
936+
}
937+
scrollViewDidEndDraggingWillDecelerate(scrollView: UIScrollView, decelerate: boolean): void {
938+
this.stopScrolling(scrollView);
939+
}
940+
941+
scrollViewDidEndScrollingAnimation(scrollView: UIScrollView): void {
942+
this.stopScrolling(scrollView);
932943
}
933944
}
934945
contentInsetAdjustmentBehaviorProperty.register(CollectionView);
@@ -1075,6 +1086,19 @@ class UICollectionViewDelegateImpl extends NSObject implements UICollectionViewD
10751086
owner.scrollViewWillEndDraggingWithVelocityTargetContentOffset(scrollView, velocity, targetContentOffset);
10761087
}
10771088
}
1089+
scrollViewDidEndDraggingWillDecelerate(scrollView: UIScrollView, decelerate: boolean): void {
1090+
const owner = this._owner.get();
1091+
if (owner) {
1092+
owner.scrollViewDidEndDraggingWillDecelerate(scrollView, decelerate);
1093+
}
1094+
}
1095+
1096+
scrollViewDidEndScrollingAnimation(scrollView: UIScrollView): void {
1097+
const owner = this._owner.get();
1098+
if (owner) {
1099+
owner.scrollViewDidEndScrollingAnimation(scrollView);
1100+
}
1101+
}
10781102
}
10791103

10801104
@NativeClass

0 commit comments

Comments
 (0)