Skip to content

Instantly share code, notes, and snippets.

@ridgehkr
Created May 17, 2013 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridgehkr/5601352 to your computer and use it in GitHub Desktop.
Save ridgehkr/5601352 to your computer and use it in GitHub Desktop.
correct a screen-zoom issue on rotation in iOS - rewritten in CoffeeScript // by @mathias, @cheeaun and @jdalton // modified by @jpamental and @ridgehkr
((doc)->
addEvent = 'addEventListener'
type = 'gesturestart'
qsa = 'querySelectorAll'
scales = [1, 1]
meta = if qsa of doc then doc[qsa]('meta[name=viewport]') else []
fix = ->
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]
doc.removeEventListener(type, fix, true)
if (meta = meta[meta.length - 1]) and addEvent of doc
do fix
scales = [0.25, 1.6]
doc[addEvent](type, fix, true)
)(document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment