Created
August 3, 2018 13:54
-
-
Save MrAlejandro/945f090302f12d98edaf9561bfad53a5 to your computer and use it in GitHub Desktop.
Grids width recalculation fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/Tygh/BlockManager/RenderManager.php b/app/Tygh/BlockManager/RenderManager.php | |
index 29183d96ae..e03d655760 100644 | |
--- a/app/Tygh/BlockManager/RenderManager.php | |
+++ b/app/Tygh/BlockManager/RenderManager.php | |
@@ -273,13 +273,16 @@ protected function recalculateGridsBoundingBox($grids, $grids_content) | |
'alpha' => 0, | |
); | |
- // Found empty first-in-row (alpha only) or in-the-middle (non-alpha and non-omega) grid. | |
- // Its width will be added to the next grid and its alpha status will be assigned to the next grid. | |
+ $is_first_in_row_and_not_single = $grid['alpha'] && !$grid['omega']; | |
+ $is_in_the_middle = !$grid['alpha'] && !$grid['omega']; | |
+ | |
if (empty($grids_content[$index]) | |
- && (($grid['alpha'] && !$grid['omega']) || (!$grid['alpha'] && !$grid['omega'])) | |
+ && ($is_first_in_row_and_not_single || $is_in_the_middle) | |
) { | |
+ // Its width will be added to the next grid and its alpha status will be assigned to the next grid. | |
$next_grid_overrides['width'] = empty($grid['fluid_width']) ? $grid['width'] : $grid['fluid_width']; | |
$next_grid_overrides['alpha'] = $grid['alpha']; | |
+ $grid['width'] = $grid['fluid_width'] = 0; | |
} | |
} | |
@@ -290,13 +293,18 @@ protected function recalculateGridsBoundingBox($grids, $grids_content) | |
'width' => 0, | |
'omega' => 0 | |
); | |
+ | |
foreach ($grids as $index => &$grid) { | |
- if (!empty($grid['fluid_width'])) { | |
+ $is_empty_grid = empty($grids_content[$index]); | |
+ | |
+ if (!empty($grid['fluid_width']) || $is_empty_grid) { | |
$grid['fluid_width'] += $prev_grid_overrides['width']; | |
} | |
- if (!empty($grid['width'])) { | |
+ | |
+ if (!empty($grid['width']) || $is_empty_grid) { | |
$grid['width'] += $prev_grid_overrides['width']; | |
} | |
+ | |
if (!empty($prev_grid_overrides['omega'])) { | |
$grid['omega'] = $prev_grid_overrides['omega']; | |
} | |
@@ -306,11 +314,13 @@ protected function recalculateGridsBoundingBox($grids, $grids_content) | |
'omega' => 0 | |
); | |
- // Found empty last-in-row (omega only) grid. | |
- // Its width will be added to previous grid and its omega status will be assigned to previous grid. | |
- if (empty($grids_content[$index]) && ($grid['omega'] && !$grid['alpha'])) { | |
+ $is_last_in_row = $grid['omega'] && !$grid['alpha']; | |
+ | |
+ if ($is_empty_grid && $is_last_in_row) { | |
+ // Its width will be added to previous grid and its omega status will be assigned to previous grid. | |
$prev_grid_overrides['width'] = empty($grid['fluid_width']) ? $grid['width'] : $grid['fluid_width']; | |
$prev_grid_overrides['omega'] = $grid['omega']; | |
+ $grid['width'] = $grid['fluid_width'] = 0; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment