Skip to content

Instantly share code, notes, and snippets.

@vyahhi
Created February 27, 2014 14:27
Show Gist options
  • Save vyahhi/9251106 to your computer and use it in GitHub Desktop.
Save vyahhi/9251106 to your computer and use it in GitHub Desktop.
##
## begin of Fullscreen + History API fix based on http://stackoverflow.com/a/21963459/92396
##
fixed_location = null
class Em.FixedHistoryLocation extends Em.HistoryLocation
implementation: 'history-fullscreen'
pathQueue = []
init: ->
fixed_location = this
super
pushState: (path)->
if screenfull.isFullscreen
pathQueue.push(path)
else
super path
fireQueue: ()->
for path in pathQueue then do (path) =>
this.pushState(path)
pathQueue = []
App.register 'location:history-fullscreen', Em.FixedHistoryLocation # for App.Router.reopen
document.addEventListener screenfull.raw.fullscreenchange, ->
if not screenfull.isFullscreen
fixed_location.fireQueue()
##
## end of Fullscreen + History API fix
##
App.Router.reopen
location: 'history-fullscreen'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment