Skip to content

Commit 0c73f3c

Browse files
committed
fix(collectionview): bring back displayItem event
1 parent a473aa9 commit 0c73f3c

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

src/collectionview/index.android.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ import {
1818
paddingTopProperty,
1919
profile
2020
} from '@nativescript/core';
21-
import { CollectionViewItemEventData, Orientation, itemOverlapProperty, reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.';
21+
import {
22+
CollectionViewItemDisplayEventData,
23+
CollectionViewItemEventData,
24+
Orientation,
25+
itemOverlapProperty,
26+
reorderLongPressEnabledProperty,
27+
reorderingEnabledProperty,
28+
reverseLayoutProperty,
29+
scrollBarIndicatorVisibleProperty
30+
} from '.';
2231
import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './index-common';
2332

2433
export * from './index-common';
@@ -1283,13 +1292,13 @@ export class CollectionView extends CollectionViewBase {
12831292
view.height = Utils.layout.toDeviceIndependentPixels(height);
12841293
}
12851294

1286-
// if (this.hasListeners(CollectionViewBase.displayItemEvent) ) {
1287-
// this.notify<CollectionViewItemDisplayEventData>({
1288-
// eventName: CollectionViewBase.displayItemEvent,
1289-
// index:position,
1290-
// object: this,
1291-
// });
1292-
// }
1295+
if (this.hasListeners(CollectionViewBase.displayItemEvent)) {
1296+
this.notify<CollectionViewItemDisplayEventData>({
1297+
eventName: CollectionViewBase.displayItemEvent,
1298+
index: position,
1299+
object: this
1300+
});
1301+
}
12931302
if (Trace.isEnabled()) {
12941303
CLog(CLogTypes.log, 'onBindViewHolder done ', position, Date.now() - start, 'ms');
12951304
}

src/collectionview/index.ios.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ import {
2020
profile
2121
} from '@nativescript/core';
2222
import { Pointer } from '@nativescript/core/ui/gestures';
23-
import { CollectionViewItemEventData, Orientation, reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.';
23+
import {
24+
CollectionViewItemDisplayEventData,
25+
CollectionViewItemEventData,
26+
Orientation,
27+
reorderLongPressEnabledProperty,
28+
reorderingEnabledProperty,
29+
reverseLayoutProperty,
30+
scrollBarIndicatorVisibleProperty
31+
} from '.';
2432
import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isBounceEnabledProperty, isScrollEnabledProperty, itemTemplatesProperty, orientationProperty } from './index-common';
2533

2634
export * from './index-common';
@@ -955,13 +963,13 @@ export class CollectionView extends CollectionViewBase {
955963
});
956964
}
957965
}
958-
// if (this.hasListeners(CollectionViewBase.displayItemEvent) ) {
959-
// this.notify<CollectionViewItemDisplayEventData>({
960-
// eventName: CollectionViewBase.displayItemEvent,
961-
// index:indexPath.row,
962-
// object: this,
963-
// });
964-
// }
966+
if (this.hasListeners(CollectionViewBase.displayItemEvent)) {
967+
this.notify<CollectionViewItemDisplayEventData>({
968+
eventName: CollectionViewBase.displayItemEvent,
969+
index: indexPath.row,
970+
object: this
971+
});
972+
}
965973

966974
if (cell.preservesSuperviewLayoutMargins) {
967975
cell.preservesSuperviewLayoutMargins = false;

0 commit comments

Comments
 (0)