1

I was trying to achieve full screen on an element in Lightning Web Components but was unable to use Document.fullscreen API.

I tried var elem = this.template.querySelector('svg');

if (elem.requestFullscreen) {
    elem.requestFullscreen();
  } else if (elem.mozRequestFullScreen) { /* Firefox */
    elem.mozRequestFullScreen();
  } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
    elem.webkitRequestFullscreen();
  } else if (elem.msRequestFullscreen) { /* IE/Edge */
    elem.msRequestFullscreen();
  }

But in LWC document component doesn't have particular functions and so was unable to implement full screen functionality.

Please help, I am quiet new in using Lightning Web Components(LWC)...

3

Locker is currently preventing access to the fullscreen API, not LWC. You can try out the following snippet of javascript in the Locker console.

document.body.requestFullscreen
// Locker OFF: function requestFullscreen() {[native code]}
// Locker ON: undefined

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.