protected function GridBase::optimizeClasses in GridStack 8.2
Optimize grid widths to remove similar widths.
2 calls to GridBase::optimizeClasses()
- BootstrapBase::itemAttributes in src/
Plugin/ gridstack/ engine/ BootstrapBase.php - Modifies the .box attributes.
- FoundationBase::itemAttributes in src/
Plugin/ gridstack/ engine/ FoundationBase.php - Modifies the .box attributes.
File
- src/
Plugin/ gridstack/ engine/ GridBase.php, line 49
Class
- GridBase
- Provides the base class for one-dimensional layout engines.
Namespace
Drupal\gridstack\Plugin\gridstack\engineCode
protected function optimizeClasses(array $settings, array $breakpoints = []) {
$root = isset($settings['_root']) ? $settings['_root'] : 'grids';
$delta = isset($settings['delta']) ? $settings['delta'] : 0;
$nid = isset($settings['nested_delta']) ? $settings['nested_delta'] : -1;
$breakpoints = $breakpoints ?: $this->breakpoints;
$unique = $region = [];
foreach (array_keys($this->sizes) as $id) {
$item = isset($breakpoints[$id], $breakpoints[$id][$root][$delta]) ? $breakpoints[$id][$root][$delta] : '';
if (empty($item)) {
continue;
}
$data = isset($item[$nid]) ? $item[$nid] : [];
$data = $root == 'nested' ? $data : $item;
// Width is at 2 from x, y, width, height, region.
if (!empty($data[2])) {
$unique[$id] = (int) $data[2];
}
// Region is at 4 from x, y, width, height, region.
if (!empty($data[4])) {
$region[] = $data[4];
}
}
$optimized = $this
->unique($unique, 2);
$optimized = $this
->unique($optimized, 3);
$column = empty($settings['optimized']) ? $unique : $optimized;
return [
'column' => $column,
'region' => $region,
];
}