div data-role="content"></div>
の高さをウィンドウの高さからフッターとヘッダーの高さを引いたものに調整するスクリプトが あります。すべて正常に動作しますが、ページが ajax 経由で DOM に読み込まれると、コンテンツ領域の高さが設定されている間に少しちらつきます
<script>
(function() {
var fixgeometry = function() {
/* Some orientation changes leave the scroll position at something
* that isn't 0,0. This is annoying for user experience. */
scroll(0, 0);
/* Calculate the geometry that our content area should take */
var header = $(".ui-header:visible");
var footer = $(".ui-footer:visible");
var content = $(".ui-content:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
/* Trim margin/border/padding height */
content_height -= (content.outerHeight() - content.height());
content.height(content_height);
}; /* fixgeometry */
$(document).ready(function() {
$(window).bind("orientationchange resize pageshow", fixgeometry);
});
})();
</script>
モバイル デバイスでテストしたときに非常に目立ち、パーセント ベースの画像が少し時間がかかり、スクリプトの実行後に調整されました。ここにjsFiddle
へのリンク
があります ちらつき効果がなくなるように、このスクリプトを最適化する方法はありますか?