I have managed to get it working via Stimulus and going to full screen is working well but for the life of me I can't work out how to exit full screen by clicking the same icon. I hope someone can help, thanks
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["fullScreen"]
connect() {
}
openFullscreen() {
if (!document.requestFullscreen) {
this.fullScreenTarget.requestFullscreen()
} else {
this.fullScreenTarget.exitFullscreen()
}
}
}
EDIT
perfect I followed the docs and added this, and it works well, is this ok? Thanks
openFullscreen() {
if (document.fullscreenElement) {
document.exitFullscreen()
} else {
this.fullScreenTarget.requestFullscreen();
}
}
}