| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | |
| 6 | 6 | class General |
| 7 | 7 | { |
| 8 | 8 | /** |
| 9 | - * @var int | |
| 9 | + * @var string | |
| 10 | 10 | */ |
| 11 | 11 | public $fullscreenMargin; |
| 12 | 12 | |
| 13 | 13 | /** |
| @@ -12,13 +12,8 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @var bool |
| 15 | 15 | */ |
| 16 | - public $autoHeight; | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * @var bool | |
| 20 | - */ | |
| 21 | 16 | public $keepAspect; |
| 22 | 17 | |
| 23 | 18 | /** |
| 24 | 19 | * @var Unit |
| @@ -58,28 +53,43 @@ | ||
| 58 | 53 | $styles = [ |
| 59 | 54 | 'default' => [] |
| 60 | 55 | ]; |
| 61 | 56 | |
| 62 | - // ignore min and max height if autoHeight is enabled or keep aspect ratio is disable | |
| 63 | - if( $this->getAllOptions()->getLayout() !== 'fullscreen' && ! $this->autoHeight && $this->keepAspect ) { | |
| 57 | + $isFullscreen = $this->getAllOptions()->getLayout() === 'fullscreen'; | |
| 64 | 58 | |
| 59 | + if( $isFullscreen || $this->keepAspect ) { | |
| 60 | + $styles = $this->getMinHeightStyles( $styles, true ); | |
| 61 | + } | |
| 62 | + | |
| 63 | + if( ! empty( $this->maxHeight->value ) && $isFullscreen ){ | |
| 64 | + $styles[ 'default' ]['max-height'] = $this->maxHeight; | |
| 65 | + } | |
| 66 | + | |
| 67 | + if( $this->backgroundColor ){ | |
| 68 | + $styles['default']['background-color'] = $this->backgroundColor; | |
| 69 | + } | |
| 70 | + | |
| 71 | + return $styles; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public function getMinHeightStyles( $styles = [], $keepAspect = null ){ | |
| 75 | + if( empty( $styles ) ){ | |
| 76 | + $styles = [ | |
| 77 | + 'default' => [] | |
| 78 | + ]; | |
| 79 | + } | |
| 80 | + | |
| 81 | + $keepAspect = $keepAspect ?? $this->keepAspect; | |
| 82 | + | |
| 83 | + if( $keepAspect ) { | |
| 65 | 84 | $heightSizes = $this->getAllOptions()->getSizes('height', false ); |
| 66 | 85 | foreach ( $heightSizes as $device => $height ){ |
| 67 | - // always add max-height for desktop size | |
| 68 | - // and add max-height for other breakpoints if max-height is less than breakpoint content height | |
| 69 | - if( $device === 'default' || $this->maxHeight < $height ){ | |
| 70 | - $styles[ $device ][ 'max-height' ] = $height . 'px'; | |
| 71 | - } | |
| 72 | - if( ! empty( $this->minHeight ) ){ | |
| 86 | + if( ! empty( $this->minHeight->value ) && ( $device === 'default' || $height > $this->minHeight->value ) ){ | |
| 73 | 87 | $styles[ $device ]['min-height'] = $this->minHeight; |
| 74 | 88 | } |
| 75 | 89 | } |
| 76 | 90 | } |
| 77 | 91 | |
| 78 | - if( $this->backgroundColor ){ | |
| 79 | - $styles['default']['background-color'] = $this->backgroundColor; | |
| 80 | - } | |
| 81 | - | |
| 82 | 92 | return $styles; |
| 83 | 93 | } |
| 84 | 94 | |
| 85 | 95 | |
| @@ -94,10 +104,12 @@ | ||
| 94 | 104 | ]; |
| 95 | 105 | $layout = $this->getAllOptions()->getLayout(); |
| 96 | 106 | |
| 97 | 107 | if( $layout == 'fullscreen' ){ |
| 98 | - if( $this->fullscreenMargin ){ | |
| 108 | + if( is_numeric( $this->fullscreenMargin ) ){ | |
| 99 | 109 | $styles['default']['height'] = "calc( 100vh - {$this->fullscreenMargin}px )"; |
| 110 | + } elseif ( $this->fullscreenMargin === 'auto' ) { | |
| 111 | + $styles['default']['height'] = "100vh"; | |
| 100 | 112 | } |
| 101 | 113 | } elseif( $layout == 'boxed' ){ |
| 102 | 114 | $responsiveSizes = $this->getAllOptions()->getSizes('width', true); |
| 103 | 115 | foreach ( $responsiveSizes as $device => $value ){ |