Skip to content

Commit 5450968

Browse files
committed
chore: refactor
1 parent 5f900cf commit 5450968

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

src/ui-pager/index.common.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ export abstract class PagerBase extends ContainerView implements AddChildFromBui
299299
super.onLayout(left, top, right, bottom);
300300
this._effectiveItemWidth = this.getMeasuredWidth() - this.effectivePaddingLeft - this.effectivePaddingRight;
301301
this._effectiveItemHeight = this.getMeasuredHeight() - this.effectivePaddingTop - this.effectivePaddingBottom;
302-
if (__IOS__ && this.iosOverflowSafeAreaEnabled) {
303-
const safeArea = this.getSafeAreaInsets();
304-
this._effectiveItemHeight += safeArea.top + safeArea.bottom;
305-
}
306302
}
307303

308304
public convertToSize(length): number {

src/ui-pager/index.ios.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export class Pager extends PagerBase {
7979
mIsRefreshing: boolean = false;
8080
mIsInit: boolean = false;
8181

82-
public mInnerWidth: number = 0;
83-
public mInnerHeight: number = 0;
82+
// public mInnerWidth: number = 0;
83+
// public mInnerHeight: number = 0;
8484
mLastLayoutKey: string;
8585

8686
constructor() {
@@ -451,7 +451,7 @@ export class Pager extends PagerBase {
451451
return;
452452
}
453453
this._isDataDirty = false;
454-
this.mLastLayoutKey = this.mInnerWidth + '_' + this.mInnerHeight;
454+
this.mLastLayoutKey = this._effectiveItemWidth + '_' + this._effectiveItemHeight;
455455

456456
// clear bindingContext when it is not observable because otherwise bindings to items won't reevaluate
457457
this.mMap.forEach((view, nativeView, map) => {
@@ -477,7 +477,7 @@ export class Pager extends PagerBase {
477477
_isDataDirty = false;
478478
public onLoaded() {
479479
super.onLoaded();
480-
if (this._isDataDirty && this.mInnerWidth !== undefined && this.mInnerHeight !== undefined) {
480+
if (this._isDataDirty && this._effectiveItemWidth !== undefined && this._effectiveItemHeight !== undefined) {
481481
this.refresh();
482482
}
483483

@@ -604,15 +604,13 @@ export class Pager extends PagerBase {
604604
});
605605
}
606606
iosOverflowSafeAreaEnabledLayoutHackNeeded = true;
607-
protected updateInnerSize() {
608-
const width = this.getMeasuredWidth();
609-
const height = this.getMeasuredHeight();
610-
this.mInnerWidth = width - this.effectivePaddingLeft - this.effectivePaddingRight;
611-
this.mInnerHeight = height - this.effectivePaddingTop - this.effectivePaddingBottom;
612-
}
607+
613608
public onLayout(left: number, top: number, right: number, bottom: number) {
614609
super.onLayout(left, top, right, bottom);
615-
this.updateInnerSize();
610+
if (this.iosOverflowSafeAreaEnabled) {
611+
const safeArea = this.getSafeAreaInsets();
612+
this._effectiveItemHeight += safeArea.top + safeArea.bottom;
613+
}
616614
if (!this.nativeView) {
617615
return;
618616
}
@@ -625,15 +623,15 @@ export class Pager extends PagerBase {
625623
layoutView.invalidateLayout();
626624

627625
const size = this._getSize();
626+
const width = Utils.layout.toDevicePixels(size.width);
627+
const height = Utils.layout.toDevicePixels(size.height);
628628
this.mMap.forEach((childView, pagerCell) => {
629-
const width = Utils.layout.toDevicePixels(size.width);
630-
const height = Utils.layout.toDevicePixels(size.height);
631629
View.layoutChild(this, childView, 0, 0, width, height);
632630
});
633631

634632
// there is no need to call refresh if it was triggered before with same size.
635633
// this refresh is just to handle size change
636-
const layoutKey = this.mInnerWidth + '_' + this.mInnerHeight;
634+
const layoutKey = this._effectiveItemWidth + '_' + this._effectiveItemHeight;
637635
if (this.mLastLayoutKey !== layoutKey) {
638636
this.refresh();
639637
}
@@ -974,7 +972,6 @@ class UICollectionDelegateImpl extends NSObject implements UICollectionViewDeleg
974972
scrollView.contentOffset = CGPointMake(Math.ceil(w) * page, scrollView.contentOffset.y);
975973
}
976974
};
977-
console.log('page', page, owner.itemCount, page === owner.itemCount);
978975
if (page === 0) {
979976
page = owner.itemCount - 2;
980977
doScroll();

0 commit comments

Comments
 (0)