Reduce cls by toggling padding value on body element
This commit is contained in:
+9
-1
@@ -9,6 +9,7 @@ export default class extends Controller {
|
|||||||
sticky: Boolean,
|
sticky: Boolean,
|
||||||
classes: String,
|
classes: String,
|
||||||
offset: Number,
|
offset: Number,
|
||||||
|
padding: String,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +36,14 @@ export default class extends Controller {
|
|||||||
this.stickyValue = window.scrollY > this.offsetValue
|
this.stickyValue = window.scrollY > this.offsetValue
|
||||||
}
|
}
|
||||||
|
|
||||||
stickyValueChanged() {
|
stickyValueChanged(value) {
|
||||||
|
if (this.hasPaddingValue) {
|
||||||
|
if (true === value) {
|
||||||
|
document.body.style.paddingTop = this.paddingValue
|
||||||
|
} else {
|
||||||
|
document.body.removeAttribute('style')
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!this.hasClassesValue) {
|
if (!this.hasClassesValue) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<f:else>
|
<f:else>
|
||||||
data-controller="sticky"
|
data-controller="sticky"
|
||||||
data-sticky-offset-value="650"
|
data-sticky-offset-value="650"
|
||||||
|
data-sticky-padding-value="7.5rem"
|
||||||
data-sticky-disabled-value="false"
|
data-sticky-disabled-value="false"
|
||||||
data-sticky-classes-value="sticky reduced"
|
data-sticky-classes-value="sticky reduced"
|
||||||
</f:else>
|
</f:else>
|
||||||
|
|||||||
Reference in New Issue
Block a user