Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: document fullscreenElement, pictureInPictureElement and visibilityState binding #8507

Merged
merged 3 commits into from
Apr 28, 2023

Conversation

ThaUnknown
Copy link
Contributor

@ThaUnknown ThaUnknown commented Apr 16, 2023

  • Tested
  • Linted
  • Adds tests
  • Adds documentation
  • Adds types

This PR adds binding for document's fullscreenElement, visibilityState and pictureInPictureElement, they are all however read only. This is useful for conditional UI which shows different things depending on fullscreen state etc

Considerations:

  1. IN THEORY the properties could be writable, but that wouldn't operate on the document element but the element that's being written aka
fullscreenElement = document.querySelector('div')

would actually be

document.querySelector('div').requestFullscreen()

but I don't think that's a good idea, so I'm leaving the properties read only.

  1. pictureInPictureElement refers only to the video PiP element, and doesn't handle the new Document Picture-in-Picture API as it uses window.documentPictureInPicture.window [????] instead of document.pictureInPictureElement to report what element is active as the current PiP window, questionable decision imho

fullscreenElement and visibilityState binding
@vercel
Copy link

vercel bot commented Apr 16, 2023

@ThaUnknown is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

fix: undefined properties
feat: tests
@ThaUnknown ThaUnknown marked this pull request as ready for review April 17, 2023 18:04
@ThaUnknown ThaUnknown changed the title feat: document fullscreenElement and visibilityState binding feat: document fullscreenElement, pictureInPictureElement and visibilityState binding Apr 17, 2023
@benmccann benmccann added this to the 3.x milestone Apr 19, 2023
@ThaUnknown
Copy link
Contributor Author

unrelated tests fail?

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Since pictureInPictureElement is not standardized (I think?) and since it sounds confusing in behavior, I suggest to just remove it from the PR - would that be ok?

@ThaUnknown
Copy link
Contributor Author

ThaUnknown commented Apr 27, 2023

Since pictureInPictureElement is not standardized

it is standardized, see this, just not implemented by firefox, since they added their own implementation for it [for some reason], even safari/opera supports it

it sounds confusing in behavior

why? it behaves identically to fullscreenElement, like actually 1:1, I'd much prefer to keep it, again, especially for conditional UI like displaying a different button when PiP is active, or hiding a video element when a custom PiP implementation is used, I originally made this PR for the PiP element, not fullscreen/visibilityState, so I'd prefer if we could keep it in

@dummdidumm
Copy link
Member

Is it a standard though? It's an editor's draft, not a recommendation, which I think means it's not officially standardized yet. I was also proposing to remove it because you said it's confusing that the new picture in picture API uses different things.

@ThaUnknown
Copy link
Contributor Author

It's an editor's draft

my bad

the new document PiP API isn't standardised, and only supported by new versions of chromium, so that was more of a note of "not to be confused with"

@dummdidumm
Copy link
Member

This is a working draft which still is not the recommended stage. I mean everyone except Firefox implemented it already anyway, so maybe it's fine.

@ThaUnknown
Copy link
Contributor Author

yeah, that's usually as far as new things will go, I agree that PiP isn't the most uuuuh agreed on thing, but there's very little stopping svelte from adding support for it, which would be nice

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's still in working draft and since the current TypeScript definitions of this repo also don't contain it, I removed the picture-in-picture binding. The rest looks good, so I'll merge - thank you!

@dummdidumm dummdidumm merged commit c4261ab into sveltejs:master Apr 28, 2023
25 of 26 checks passed
@ThaUnknown
Copy link
Contributor Author

that's insanely sad

@Conduitry
Copy link
Member

The fullscreenElement and visibilityState bindings have been released in 3.59.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants