@@ -52,6 +52,15 @@ class MenuStyle
5252 */
5353 private $ requestedWidth ;
5454
55+ /**
56+ * If the window was resized, we store the original
57+ * size, before any resizing, to attempt to restore
58+ * it on a later resize.
59+ *
60+ * @var int
61+ */
62+ private $ widthBeforeResize ;
63+
5564 /**
5665 * @var int
5766 */
@@ -402,6 +411,7 @@ public function setWidth(int $width) : self
402411 $ this ->requestedWidth = $ width ;
403412 $ width = $ this ->maybeShrinkWidth ($ this ->margin , $ width );
404413
414+ $ this ->widthBeforeResize = null ;
405415 $ this ->width = $ width ;
406416 if ($ this ->marginAuto ) {
407417 $ this ->calculateMarginAuto ($ width );
@@ -423,6 +433,24 @@ private function maybeShrinkWidth(int $margin, int $width) : int
423433 return $ width ;
424434 }
425435
436+ public function windowResize () : void
437+ {
438+ if (null === $ this ->widthBeforeResize ) {
439+ $ this ->widthBeforeResize = $ this ->width ;
440+ }
441+
442+ $ width = $ this ->maybeShrinkWidth ($ this ->margin , $ this ->widthBeforeResize );
443+
444+ $ this ->width = $ width ;
445+ if ($ this ->marginAuto ) {
446+ $ this ->calculateMarginAuto ($ width );
447+ }
448+
449+ $ this ->calculateContentWidth ();
450+ $ this ->generateBorderRows ();
451+ $ this ->generatePaddingTopBottomRows ();
452+ }
453+
426454 public function getPaddingTopBottom () : int
427455 {
428456 return $ this ->paddingTopBottom ;
0 commit comments