Skip to content

Commit 6aea34b

Browse files
committed
fix: allow crazier configs
1 parent 2dedce2 commit 6aea34b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,20 @@ export class Drawer extends GridLayout {
102102
translationFunction?: (
103103
side: Side,
104104
width: number,
105+
value: number,
105106
delta: number,
106107
progress: number
107108
) => { leftDrawer?: AnimationDefinition; rightDrawer?: AnimationDefinition; backDrop?: AnimationDefinition; mainContent?: AnimationDefinition };
108109

109110
constructor() {
110111
super();
111-
// this.isPassThroughParentEnabled = true;
112+
this.isPassThroughParentEnabled = true;
112113
this.backDrop = new GridLayout();
113114
this.backDrop.backgroundColor = this.backdropColor;
114115
this.backDrop.opacity = 0;
115116
this.backDrop.visibility = 'hidden';
116-
117+
117118
this.insertChild(this.backDrop, 0);
118-
// console.log('Drawer constructor', this.backDrop, this.getChildIndex(this.backDrop));
119119
}
120120
initGestures() {
121121
const manager = Manager.getInstance();
@@ -290,7 +290,7 @@ export class Drawer extends GridLayout {
290290
const delta = Math.max(width - value, 0);
291291
const progress = delta / width;
292292
if (this.translationFunction) {
293-
return this.translationFunction(side, width, delta, progress);
293+
return this.translationFunction(side, width, value, delta, progress);
294294
}
295295
if (this.modes[side] === 'under') {
296296
return {
@@ -370,8 +370,6 @@ export class Drawer extends GridLayout {
370370
this.needToSetSide = 'right';
371371
this.rightDrawer.visibility = 'visible';
372372
}
373-
// console.log('show backDrop');
374-
// this.backDrop.visibility = 'visible';
375373
}
376374
this.updateIsPanning(state);
377375

@@ -434,7 +432,7 @@ export class Drawer extends GridLayout {
434432
this.needToSetSide = null;
435433
// (side === 'left' ? this.leftDrawer : this.rightDrawer).visibility = 'visible';
436434
// console.log('show backDrop');
437-
this.backDrop.visibility = 'visible';
435+
// this.backDrop.visibility = 'visible';
438436
}
439437
const width = this.viewWidth[side];
440438

@@ -449,6 +447,7 @@ export class Drawer extends GridLayout {
449447

450448
this.translationX[side] = width + trX;
451449
const trData = this.computeTranslationData(side, width + trX);
450+
this.backDrop.visibility = trData.backDrop && trData.backDrop.opacity > 0 ? 'visible' : 'hidden';
452451
this.applyTrData(trData, side);
453452
this.updateIsPanning(data.state);
454453
this.prevDeltaX = deltaX;
@@ -483,7 +482,10 @@ export class Drawer extends GridLayout {
483482
if (position !== 0) {
484483
this.showingSide = side;
485484
(side === 'right' ? this.rightDrawer : this.leftDrawer).visibility = 'visible';
486-
this.backDrop.visibility = 'visible';
485+
if (trData.backDrop && trData.backDrop.opacity > 0) {
486+
this.backDrop.opacity = 0;
487+
this.backDrop.visibility = trData.backDrop && trData.backDrop.opacity > 0 ? 'visible' : 'hidden';
488+
}
487489
this.notify({ eventName: 'open', side, duration } as DrawerEventData);
488490
} else {
489491
this.showingSide = null;
@@ -512,8 +514,9 @@ export class Drawer extends GridLayout {
512514
}
513515
if (position !== 0) {
514516
} else {
515-
// console.log('hide backDrop');
516-
this.backDrop.visibility = 'hidden';
517+
if (trData.backDrop) {
518+
this.backDrop.visibility = 'hidden';
519+
}
517520
}
518521
}
519522
isSideOpened() {

0 commit comments

Comments
 (0)