Skip to content

Commit 385b95d

Browse files
committed
fix: regression fix causing first opening to be without animatino
1 parent fdd39db commit 385b95d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ui-drawer/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export class Drawer extends GridLayout {
123123
private isAnimating = false;
124124
private prevDeltaX = 0;
125125
private prevDeltaY = 0;
126-
private viewWidth: { [k in Side]: number } = { left: 0, right: 0 };
127-
private viewHeight: { [k in VerticalSide]: number } = { bottom: 0, top: 0 };
126+
private viewWidth: { [k in Side]: number } = { left: undefined, right: undefined };
127+
private viewHeight: { [k in VerticalSide]: number } = { bottom: undefined, top: undefined };
128128
private translationX: { [k in Side]: number } = { left: 0, right: 0 };
129129
private translationY: { [k in VerticalSide]: number } = { bottom: 0, top: 0 };
130130
private showingSide: Side | VerticalSide = null;
@@ -612,6 +612,8 @@ export class Drawer extends GridLayout {
612612
let data;
613613
let safeAreaOffset = 0;
614614
let changed = false;
615+
const getMeasuredWidth = () => (Application.orientation() === 'landscape' ? contentView.getMeasuredHeight() : contentView.getMeasuredWidth());
616+
const getMeasuredHeight = () => (Application.orientation() === 'landscape' ? contentView.getMeasuredWidth() : contentView.getMeasuredHeight());
615617
if (side === 'left' || side === 'right') {
616618
if (__IOS__) {
617619
const deviceOrientation = UIDevice.currentDevice.orientation;
@@ -622,11 +624,14 @@ export class Drawer extends GridLayout {
622624
}
623625
}
624626
const width = Math.ceil(Utils.layout.toDeviceIndependentPixels(contentView.getMeasuredWidth()) + safeAreaOffset);
627+
const firstSet = this.viewWidth[side] === undefined;
625628
changed = width !== this.viewWidth[side];
626629
this.viewWidth[side] = width;
627-
// contentView.translateX = 0;
628630
if (this.translationX[side] === 0) {
629631
//opened: we dont need to do anything as no translation
632+
if (firstSet) {
633+
data = this.computeTranslationData(side, width);
634+
}
630635
} else {
631636
const shown = this.viewWidth[side] - this.translationX[side];
632637
data = this.computeTranslationData(side, width - shown);
@@ -635,12 +640,14 @@ export class Drawer extends GridLayout {
635640
} else {
636641
safeAreaOffset = __IOS__ && Application.ios.window.safeAreaInsets ? Application.ios.window.safeAreaInsets.bottom : 0;
637642
const height = Math.ceil(Utils.layout.toDeviceIndependentPixels(contentView.getMeasuredHeight()) + safeAreaOffset);
643+
const firstSet = this.viewHeight[side] === undefined;
638644
changed = height !== this.viewHeight[side];
639645
this.viewHeight[side] = height;
640646
if (this.translationY[side] === 0) {
641647
//opened: we dont need to do anything as no translation
642-
// data = this.computeTranslationData(side, height);
643-
// this.translationY[side] = height;
648+
if (firstSet) {
649+
data = this.computeTranslationData(side, height);
650+
}
644651
} else {
645652
const shown = this.viewHeight[side] - this.translationY[side];
646653
data = this.computeTranslationData(side, height - shown);

0 commit comments

Comments
 (0)