|
12 | 12 | trait Scroller |
13 | 13 | { |
14 | 14 | /** |
15 | | - * Set scroller option value. |
| 15 | + * Set scroller boundaryScale option value. |
16 | 16 | * |
17 | | - * @param bool|array $value |
| 17 | + * @param float $value |
18 | 18 | * @return $this |
19 | | - * @see https://datatables.net/reference/option/scroller |
| 19 | + * @see https://datatables.net/reference/option/scroller.boundaryScale |
20 | 20 | */ |
21 | | - public function scroller(bool|array $value = true): static |
| 21 | + public function scrollerBoundaryScale(float $value = 0.5): static |
22 | 22 | { |
23 | | - $this->attributes['scroller'] = $value; |
24 | | - |
25 | | - return $this; |
| 23 | + return $this->scroller(['boundaryScale' => $value]); |
26 | 24 | } |
27 | 25 |
|
28 | 26 | /** |
29 | | - * Set scroller boundaryScale option value. |
| 27 | + * Set scroller option value. |
30 | 28 | * |
31 | | - * @param float $value |
| 29 | + * @param bool|array $value |
32 | 30 | * @return $this |
33 | | - * @see https://datatables.net/reference/option/scroller.boundaryScale |
| 31 | + * @see https://datatables.net/reference/option/scroller |
34 | 32 | */ |
35 | | - public function scrollerBoundaryScale(float $value = 0.5): static |
| 33 | + public function scroller(bool|array $value = true): static |
36 | 34 | { |
37 | | - return $this->scroller(['boundaryScale' => $value]); |
| 35 | + if (is_array($value)) { |
| 36 | + $this->attributes['scroller'] = array_merge((array) $this->attributes['scroller'], $value); |
| 37 | + } else { |
| 38 | + $this->attributes['scroller'] = $value; |
| 39 | + } |
| 40 | + |
| 41 | + return $this; |
38 | 42 | } |
39 | 43 |
|
40 | 44 | /** |
@@ -84,4 +88,17 @@ public function scrollerServerWait(int $value = 200): static |
84 | 88 | { |
85 | 89 | return $this->scroller(['serverWait' => $value]); |
86 | 90 | } |
| 91 | + |
| 92 | + /** |
| 93 | + * @param string|null $key |
| 94 | + * @return mixed |
| 95 | + */ |
| 96 | + public function getScroller(string $key = null): mixed |
| 97 | + { |
| 98 | + if (is_null($key)) { |
| 99 | + return $this->attributes['scroller'] ?? true; |
| 100 | + } |
| 101 | + |
| 102 | + return $this->attributes['scroller'][$key] ?? false; |
| 103 | + } |
87 | 104 | } |
0 commit comments