Skip to content

Commit 06eb203

Browse files
committed
Merge pull request #233 from BrandonLWhite/master
Resolved issue with FlashOfUnstyledContent (FOUC) when using jQuery Mobile
2 parents 57a91ad + bc4ad02 commit 06eb203

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

js/jquery.keyboard.extension-mobile.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,21 @@ $.fn.addMobile = function(options){
6363
base.mobile_setup();
6464
}
6565

66-
// Setup mobile theme on keyboard once it is visible
67-
base.$el.bind('visible.keyboard', function() {
66+
// Setup mobile theme on keyboard once it is visible.
67+
// Note: There is a 10ms delay after the keyboard is displayed before it actually fires 'visible.keyboard'.
68+
// Since we are restyling here, the user will experience FlashOfUnstyledContent (FOUC).
69+
// This is avoided by first setting the visibility to hidden, then after the mobile styles are applied we
70+
// set it visible.
71+
//
72+
base.$el.on('beforeVisible.keyboard', function () {
73+
if (base.mobile_initialized !== true) {
74+
base.$keyboard.css("visibility", "hidden");
75+
}
76+
})
77+
.on('visible.keyboard', function () {
6878
if (base.mobile_initialized !== true) {
6979
base.mobile_setup();
80+
base.$keyboard.css("visibility", "visible");
7081
}
7182
});
7283

0 commit comments

Comments
 (0)