Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix resizing issue with iOS
<?php
/**
* Enqueue iOS bug fix
*
*/
function be_enqueue_ios_bug_fix() {
wp_enqueue_script( 'be-ios-bug', get_stylesheet_directory_uri() . '/lib/js/ios-bug.js' );
}
add_action( 'wp_enqueue_scripts', 'be_enqueue_ios_bug_fix' );
(function(doc) {
var addEvent = 'addEventListener',
type = 'gesturestart',
qsa = 'querySelectorAll',
scales = [1, 1],
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
function 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]) && addEvent in doc) {
fix();
scales = [.25, 1.6];
doc[addEvent](type, fix, true);
}
}(document));
@jaredatch

This comment has been minimized.

Copy link

jaredatch commented Aug 16, 2012

I haven't seen this function before, what bug does it address?

@ghost

This comment has been minimized.

Copy link

ghost commented Aug 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.