前提
開発しているWebサイトで、iOS13(Safari13)以下の環境でのみ(おそらく)javascriptでエラーになってしまいます。
同様のページをiOS14以上やPC各ブラウザで表示する際には問題ありません。
環境的に問題端末でコンソールを確認したりすることが出来ませんが、更新履歴から問題点らしき箇所は絞り込みました。
該当ページの構成としては
・PHPでページ自体の構成を管理
・ページ内の一部の機能をJavaScriptで制御
・一部でReactやjQueryも使用
といった構成で動作させています。
追記
JQuery バージョンは3.3.1
発生している問題・エラーメッセージ
該当のページをSafari13以下の環境で表示した際に、PHPで表示させている部分までは表示されているが、JavaScriptで制御している部分から表示されなくなってしまう
Safari14以上や、PCのChrome、AndroidのChromeでは問題なくページ全体が表示され動作する。
該当のソースコード
関連していると思われるソースが二つありますのでそれぞれ記載します。
ソース一つ目
表示出来るタイミングでの関連と思われる部分のコード
JavaScript
1const adjustHeight = function(){ 2 const $target = $('.hogeClass'); 3 const $marginSize = 110; 4 5 const HeaderHeight = $('.content1').outerHeight(true) + $('.content2').outerHeight(true) + $('.content3').height(); 6 const contentHeight = $(window).height() - (HeaderHeight + $marginSize); 7 8 $target.css({ 9 'height': `${contentHeight}px`, 10 }) 11}
表示出来なくなったタイミングでの更新後のコード
JavaScript
1const adjustHeight = function(){ 2 const $target = $('.hogeClass'); 3 const marginSize = 110; 4 5 const hogeHeight= ($(this).hasClass('[class=hoge1]')) ? $('.hoge1').outerHeight(true) : 0; 6 const hogeHeaderHeight = $('.hogehoge1').outerHeight(true) + $('.hogehoge2').outerHeight(true) + $('.hogehoge3').height() + hogeHeight; 7 const hogeVPHeight = ('visualViewport' in window) ? 8 (window.visualViewport.height - (hogeHeaderHeight + marginSize)) : 9 (window.innerWidth - (hogeHeaderHeight + marginSize)); 10 11 $target.css({ 12 'height': `${hogeVPHeight}px`, 13 }) 14 15 }
ソース二つ目
表示出来るタイミングでの関連と思われる部分のコード
JavaScript
1 const ADJUSTMENT_VALUE = 100; 2 const doc = document.documentElement; 3 const body = document.body; 4 const scrollLeft = doc.scrollLeft || body.scrollLeft; 5 const scrollTop = doc.scrollTop || body.scrollTop; 6 7 const offsetTop = $(options.offsetTopLeftSelector).offset().top + $(options.offsetTopLeftSelector).height() - ADJUSTMENT_VALUE; 8 const offsetLeft = $(options.offsetTopLeftSelector).offset().left - scrollLeft + CARSLISTWIDTH / 2 - BUTTONWIDTH / 2; 9 const offsetBottom = $(options.offsetBottomSelector).offset().top - $(options.offsetBottomSelector).height() - targetHeight - options.elementFixedBottom; 10 const reachToBottom = scrollTop + $(window).height() - ADJUSTMENT_VALUE; 11 const top = $(window).height() - targetHeight - options.elementMarginBottom;
表示出来なくなったタイミングでの更新後のコード
JavaScript
1 const ADJUSTMENT_VALUE = 100; 2 const doc = document.documentElement; 3 const body = document.body; 4 const scrollTop = doc.scrollTop || body.scrollTop; 5 6 const offsetTop = $(options.offsetTopLeftSelector).offset().top + $(options.offsetTopLeftSelector).height() - ADJUSTMENT_VALUE; 7 const offsetBottom = $(options.offsetBottomSelector).offset().top - $(options.offsetBottomSelector).height() - targetHeight - options.elementFixedBottom; 8 const top = scrollTop + window.visualViewport.height - targetHeight - options.elementMarginBottom; 9 const reachToBottom = scrollTop + $(window).height() - ADJUSTMENT_VALUE; 10 const hoge1Width = doc.querySelector('[class=hoge1]').offsetWidth; 11 const hoge2Half = doc.querySelector('[class=hoge2]').offsetWidth / 2; 12 const hoge3Bottom = doc.querySelector('[class=hoge3]').offsetBottom; 13 const hoge4Half = document.getElementById('hoge4').offsetWidth / 2; 14 const margin = 20; 15 const positionLeft = hoge1Width + hoge2Half + margin - hoge4Half; 16 const positionTop = hoge3Bottom + scrollTop + margin;
試したこと
表示されなくなってしまったタイミングのコミットから遡り、表示出来るタイミングのコミットとの差異を絞り込みました。
JavaScriptでのHTML要素の取得に関する記述がほとんどのため、これらの記述で問題のある記述があるか知りたいです。
iOSでの挙動に明るくないため、iOS13~14(Safari13~14)の間でこれらに関連する変更があったかどうかの知見があまりありません。非推奨になったりしている記述があれば指摘いただけると助かります。よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー