mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
27 lines
657 B
JavaScript
27 lines
657 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
connect() {
|
|
this.updateViewport()
|
|
|
|
this.boundResize = this.handleResize.bind(this)
|
|
|
|
window.addEventListener("resize", this.boundResize)
|
|
window.addEventListener("orientationchange", this.boundResize)
|
|
}
|
|
|
|
disconnect() {
|
|
window.removeEventListener("resize", this.boundResize)
|
|
window.removeEventListener("orientationchange", this.boundResize)
|
|
}
|
|
|
|
handleResize() {
|
|
this.updateViewport()
|
|
}
|
|
|
|
updateViewport() {
|
|
const height = window.innerHeight
|
|
document.documentElement.style.setProperty("--app-height", `${height}px`)
|
|
}
|
|
}
|