This commit is contained in:
19
app/javascript/controllers/fullscreen_controller.js
Normal file
19
app/javascript/controllers/fullscreen_controller.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["button"]
|
||||
|
||||
connect() {
|
||||
if (!this.element.requestFullscreen) {
|
||||
this.buttonTarget.remove()
|
||||
}
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (!document.fullscreenElement) {
|
||||
document.documentElement.requestFullscreen()
|
||||
} else if (document.exitFullscreen) {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user