Skip to content

Conversation

Copy link

Copilot AI commented Nov 25, 2025

Safari's IntersectionObserver fails to trigger inView callbacks when rootMargin uses extreme negative values like -1000px. This caused sections to not appear on Safari while working correctly on Chrome/Firefox.

Changes

  • Reduced rootMargin values to stay within target element heights (~300px):

    • XL (≥1280px): -1000px-300px
    • SM (≥640px): -350px-200px
    • Base: -200px-100px
  • Refactored duplicated logic into shared function:

const getResponsiveRootMargin = (): string => {
  if (window.innerWidth >= 1280) return "-300px";
  if (window.innerWidth >= 640) return "-200px";
  return "-100px";
};

const inViewOptions = {
  rootMargin: getResponsiveRootMargin(),
  triggerOnce: true,
};

const [ref1, inView1] = useInView(inViewOptions);
const [ref2, inView2] = useInView(inViewOptions);
// ...
Original prompt

This section details on the original issue you should resolve

<issue_title>safari において一部セクションが表示されない</issue_title>
<issue_description># 問題概要

  • Safariでのみ、一部セクションが正常に表示されない

詳細

  • 該当要素は IntersectionObserverinView 判定に依存
  • rootMargin-1000px のような大きな負値に設定している
    if (window.innerWidth >= 1280) return "-1000px";
  • 対象要素の高さは約 300px

原因

  • Safari は IntersectionObserverrootMargin 設定が極端なマイナス値だと、inView 判定が正常に機能しない
  • 他ブラウザ(Chrome/Firefox)では動作するが、Safari では判定ロジックの違い・バグにより発火しない可能性が高い

解決策

  • rootMargin の絶対値を(おそらく)対象の高さ以内に抑える必要がある
    • ex) -1000px -> -300px 程度に修正
  • 値を調整した上で Safari・他ブラウザ双方で動作確認を行う</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 25, 2025 18:11
Co-authored-by: wappon28dev <86721991+wappon28dev@users.noreply.github.com>
Co-authored-by: wappon28dev <86721991+wappon28dev@users.noreply.github.com>
Co-authored-by: wappon28dev <86721991+wappon28dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix section display issue in Safari with IntersectionObserver Fix Safari IntersectionObserver by reducing extreme rootMargin values Nov 25, 2025
Copilot AI requested a review from wappon28dev November 25, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

safari において一部セクションが表示されない

2 participants