@@ -207,10 +207,6 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
207
207
:host([stack]) [part='detail'] {
208
208
inset: 0;
209
209
}
210
-
211
- [part='master']::before {
212
- background-position-y: var(--_stack-threshold);
213
- }
214
210
` ;
215
211
}
216
212
@@ -291,6 +287,9 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
291
287
* there is enough space for master and detail to be shown next to
292
288
* each other using the default (split) mode.
293
289
*
290
+ * In order to enforce the stack mode, use this property together with
291
+ * `stackOverlay` property and set both to `true`.
292
+ *
294
293
* @attr {boolean} force-overlay
295
294
*/
296
295
forceOverlay : {
@@ -314,14 +313,18 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
314
313
} ,
315
314
316
315
/**
317
- * The threshold (in CSS length units) at which the layout switches to
318
- * the "stack" mode, making detail area fully cover the master area.
316
+ * When true, the layout in the overlay mode is rendered as a "stack",
317
+ * making detail area fully cover the master area.
318
+ *
319
+ * In order to enforce the stack mode, use this property together with
320
+ * `forceOverlay` property and set both to `true`.
319
321
*
320
322
* @attr {string} stack-threshold
321
323
*/
322
- stackThreshold : {
323
- type : String ,
324
- observer : '__stackThresholdChanged' ,
324
+ stackOverlay : {
325
+ type : Boolean ,
326
+ value : false ,
327
+ observer : '__stackOverlayChanged' ,
325
328
sync : true ,
326
329
} ,
327
330
@@ -337,7 +340,6 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
337
340
338
341
/**
339
342
* When true, the component uses the overlay mode. This property is read-only.
340
- * In order to enforce the overlay mode, use `forceOverlay` property.
341
343
* @protected
342
344
*/
343
345
_overlay : {
@@ -349,7 +351,6 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
349
351
350
352
/**
351
353
* When true, the component uses the stack mode. This property is read-only.
352
- * In order to enforce the stack mode, use `stackThreshold` property.
353
354
* @protected
354
355
*/
355
356
_stack : {
@@ -463,14 +464,8 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
463
464
}
464
465
465
466
/** @private */
466
- __stackThresholdChanged ( threshold , oldThreshold ) {
467
- if ( threshold || oldThreshold ) {
468
- if ( threshold ) {
469
- this . $ . master . style . setProperty ( '--_stack-threshold' , threshold ) ;
470
- } else {
471
- this . $ . master . style . removeProperty ( '--_stack-threshold' ) ;
472
- }
473
-
467
+ __stackOverlayChanged ( stackOverlay , oldStackOverlay ) {
468
+ if ( stackOverlay || oldStackOverlay ) {
474
469
this . __detectLayoutMode ( ) ;
475
470
}
476
471
}
@@ -486,30 +481,25 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
486
481
this . toggleAttribute ( `has-${ prop } ` , ! ! size ) ;
487
482
}
488
483
484
+ /** @private */
485
+ __setOverlayMode ( value ) {
486
+ if ( this . stackOverlay ) {
487
+ this . _stack = value ;
488
+ } else {
489
+ this . _overlay = value ;
490
+ }
491
+ }
492
+
489
493
/** @private */
490
494
__detectLayoutMode ( ) {
491
495
this . _overlay = false ;
492
496
this . _stack = false ;
493
497
494
498
if ( this . forceOverlay ) {
495
- this . _overlay = true ;
499
+ this . __setOverlayMode ( true ) ;
496
500
return ;
497
501
}
498
502
499
- if ( this . stackThreshold != null ) {
500
- // Set stack to true to disable masterMinSize and detailMinSize
501
- // that would affect size measurements below when in split mode
502
- this . _stack = true ;
503
-
504
- const threshold = this . __getStackThresholdInPixels ( ) ;
505
- const size = this . orientation === 'vertical' ? this . offsetHeight : this . offsetWidth ;
506
- if ( size > threshold ) {
507
- this . _stack = false ;
508
- } else {
509
- return ;
510
- }
511
- }
512
-
513
503
if ( ! this . _hasDetail ) {
514
504
return ;
515
505
}
@@ -535,38 +525,28 @@ class MasterDetailLayout extends SlotStylesMixin(ResizeMixin(ElementMixin(Themab
535
525
536
526
// If the combined minimum size of both the master and the detail content
537
527
// exceeds the size of the layout, the layout changes to the overlay mode.
538
- this . _overlay = this . offsetWidth < masterWidth + detailWidth ;
528
+ this . __setOverlayMode ( this . offsetWidth < masterWidth + detailWidth ) ;
539
529
540
530
// Toggling the overlay resizes master content, which can cause document
541
531
// scroll bar to appear or disappear, and trigger another resize of the
542
532
// layout which can affect previous measurements and end up in horizontal
543
533
// scroll. Check if that is the case and if so, preserve the overlay mode.
544
534
if ( this . offsetWidth < this . scrollWidth ) {
545
- this . _overlay = true ;
535
+ this . __setOverlayMode ( true ) ;
546
536
}
547
537
}
548
538
549
539
/** @private */
550
540
__detectVerticalMode ( ) {
551
- // Remove overlay attribute temporarily to detect if there is enough space
552
- // for both areas so that layout could switch back to the split mode.
553
- this . _overlay = false ;
554
-
555
541
const masterHeight = this . $ . master . clientHeight ;
556
542
557
543
// If the combined minimum size of both the master and the detail content
558
544
// exceeds the available height, the layout changes to the overlay mode.
559
545
if ( this . offsetHeight < masterHeight + this . $ . detail . clientHeight ) {
560
- this . _overlay = true ;
546
+ this . __setOverlayMode ( true ) ;
561
547
}
562
548
}
563
549
564
- /** @private */
565
- __getStackThresholdInPixels ( ) {
566
- const { backgroundPositionY } = getComputedStyle ( this . $ . master , '::before' ) ;
567
- return parseFloat ( backgroundPositionY ) ;
568
- }
569
-
570
550
/**
571
551
* Sets the detail element to be displayed in the detail area and starts a
572
552
* view transition that animates adding, replacing or removing the detail
0 commit comments