Closed alexbainter closed 5 years ago
What is the downside (to the user) of accidentally leaving the site? Losing pieces? Is the currently playing piece something that could be stored in localStorage
so they can resume if they re-open within a certain period? That would be a less intrusive solution.
@cdtinney I had a user email saying they kept accidentally closing out of the site, so this is my short term easy solution for preventing that. This is the same behavior of Google Play Music's web player so I'm comfortable with the intrusiveness.
@metalex9 To play devils advocate -- Spotify/YouTube/SoundCloud don't do this
Good point but I'm betting that more users will benefit from this behavior than be annoyed be it. Chrome allows you to prevent popups for a site if you really can't stand it. If the site ever warrants a settings page I will allow this to be turned off.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
This prevents users from accidentally closing the site while only mildly annoying users who actually want to leave.
Don't do this on mobile (some devices don't support it anyway).