Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Updating fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jansepar committed Sep 27, 2014
1 parent d3967dc commit 6f17353
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
33 changes: 21 additions & 12 deletions api/main.js
Expand Up @@ -92,22 +92,31 @@ $.extend(Mobify.transform, {
timing.logPoints();
}

var write = function(){
// We'll write markup a tick later, as Firefox logging is async
// and gets interrupted if followed by synchronous document.open
window.setTimeout(function(){
// `document.open` clears events bound to `document`.
document.open();

// In Webkit, `document.write` immediately executes inline scripts
// not preceded by an external resource.
document.write(markup);
document.close();
});
};

if (Mobify.isIOS8_0()){
// See `utils.js` for more information about this fix.
Mobify.ios8_0ScrollFix(document);
window.requestAnimationFrame(function(){
window.requestAnimationFrame(function(){
write();
})
})
} else {
write();
}

// We'll write markup a tick later, as Firefox logging is async
// and gets interrupted if followed by synchronous document.open
window.setTimeout(function(){
// `document.open` clears events bound to `document`.
document.open();

// In Webkit, `document.write` immediately executes inline scripts
// not preceded by an external resource.
document.write(markup);
document.close();
});
},

// Kickstart processing. Guard against beginning before the document is ready.
Expand Down
9 changes: 3 additions & 6 deletions api/util.js
Expand Up @@ -40,18 +40,15 @@ Mobify.isIOS8_0 = function() {
* capturing, the initial document never has an active meta viewport tag.
* Then, the rendered document injects one causing the aforementioned scroll.
*
* This patches HTML to hide the body until the first paint (and hopefully after
* the initial viewport is calculated). By the time we show the body the new
* viewport should have already taken effect.
* Create a meta viewport tag that we inject into the page to force the
* page to scroll before anything is rendered in the page
* (this code should be called before document.open!)
*
* JIRA: https://mobify.atlassian.net/browse/GOLD-883
* Open Radar: http://www.openradar.me/radar?id=5516452639539200
* WebKit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=136904
*/
Mobify.ios8_0ScrollFix = function(doc) {
// Create a meta viewport tag that we inject into the page to force the
// page to scroll before anything is rendered in the page
// (this code should be called before document.open!)
var meta = document.createElement('meta');
meta.setAttribute('name', 'viewport');
meta.setAttribute('content', 'width=device-width');
Expand Down

0 comments on commit 6f17353

Please sign in to comment.