Skip to content

Commit 4ae97fa

Browse files
author
farfromrefug
committed
fix: new allowCssPropagation property (false by default)
1 parent 8d20a52 commit 4ae97fa

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/collectionview/index-common.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export abstract class CollectionViewBase extends View implements CollectionViewD
113113
public static dataPopulatedEvent = 'dataPopulated';
114114
public static knownFunctions = ['itemTemplateSelector', 'itemIdGenerator', 'spanSize']; // See component-builder.ts isKnownFunction
115115

116+
public allowCssPropagation: boolean;
116117
public isBounceEnabled: boolean;
117118
public isScrollEnabled: boolean;
118119
public reverseLayout: boolean;
@@ -736,6 +737,13 @@ export const autoReloadItemOnLayoutProperty = new Property<CollectionViewBase, b
736737
});
737738
autoReloadItemOnLayoutProperty.register(CollectionViewBase);
738739

740+
export const allowCssPropagationProperty = new Property<CollectionViewBase, boolean>({
741+
name: 'allowCssPropagation',
742+
defaultValue: false,
743+
valueConverter: booleanConverter
744+
});
745+
allowCssPropagationProperty.register(CollectionViewBase);
746+
739747
export const itemOverlapProperty = new Property<CollectionViewBase, Function>({
740748
name: 'itemOverlap',
741749
defaultValue: undefined,

src/collectionview/index.android.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,11 +1248,15 @@ export class CollectionView extends CollectionViewBase {
12481248
parentView.id = 'collectionViewHolder';
12491249
view = parentView;
12501250
}
1251-
//@ts-ignore
1252-
view.parent = this;
1253-
view._setupAsRootView(this._context);
1254-
view._isAddedToNativeVisualTree = true;
1255-
view.callLoaded();
1251+
1252+
if (this.allowCssPropagation) {
1253+
this._addView(view);
1254+
} else {
1255+
view.parent = this;
1256+
view._setupAsRootView(this._context);
1257+
view._isAddedToNativeVisualTree = true;
1258+
view.callLoaded();
1259+
}
12561260
if (!CollectionViewCellHolder) {
12571261
CollectionViewCellHolder = com.nativescript.collectionview.CollectionViewCellHolder as any;
12581262
}

src/collectionview/index.ios.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export enum SnapPosition {
8484
END = 1 // = androidx.recyclerview.widget.LinearSmoothScroller.SNAP_TO_END
8585
}
8686

87-
8887
export class CollectionView extends CollectionViewBase {
8988
//TODO: remove as it needs to be added after TS 5.7 change https://github.com/microsoft/TypeScript/pull/59860
9089
[key: symbol]: (...args: any[]) => any | void;
@@ -837,7 +836,7 @@ export class CollectionView extends CollectionViewBase {
837836
scrollToOffset(value, animated) {
838837
const view = this.nativeViewProtected;
839838
if (view && this.isScrollEnabled) {
840-
const { width, height } = view.bounds.size;
839+
const { height, width } = view.bounds.size;
841840
let rect: CGRect;
842841
if (this.orientation === 'vertical') {
843842
rect = CGRectMake(0, value, width, height);
@@ -924,7 +923,14 @@ export class CollectionView extends CollectionViewBase {
924923
}
925924

926925
if (view && !view.parent) {
927-
this._addView(view);
926+
if (this.allowCssPropagation) {
927+
this._addView(view);
928+
} else {
929+
view.parent = this;
930+
view._setupAsRootView(this._context);
931+
view._isAddedToNativeVisualTree = true;
932+
view.callLoaded();
933+
}
928934
const innerView = NSCellView.new() as NSCellView;
929935
innerView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
930936
innerView.view = new WeakRef(view);

0 commit comments

Comments
 (0)