scale.fix.js 503 B

1234567891011121314151617181920
  1. fixScale = function(doc) {
  2. var addEvent = 'addEventListener',
  3. type = 'gesturestart',
  4. qsa = 'querySelectorAll',
  5. scales = [1, 1],
  6. meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
  7. function fix() {
  8. meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
  9. doc.removeEventListener(type, fix, true);
  10. }
  11. if ((meta = meta[meta.length - 1]) && addEvent in doc) {
  12. fix();
  13. scales = [.25, 1.6];
  14. doc[addEvent](type, fix, true);
  15. }
  16. };