Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
IntersectionObserverはいいぞ
Search
Leko
September 15, 2017
Programming
3.2k
3
Share
IntersectionObserverはいいぞ
IntersectionObserverを使っていただきたいだけの話
Leko
September 15, 2017
More Decks by Leko
See All by Leko
コンセプトの海の泳ぎ方
leko
0
46
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
3
360
エンジニアと治療アプリ®
leko
0
1.3k
Node.jsにContributeして一ヶ月でCollaboratorになった
leko
5
7.5k
React NativeアプリでE2Eテストを回してみた
leko
8
2.9k
React Nativeで医療機器作ってます
leko
4
1.8k
趣味では使っているが 仕事には使ってないツール
leko
1
250
レガシーな開発現場にUTを入れてCIを導入した話
leko
0
6.4k
MySQLがゆるふわなのはどう考えてもSQLモードが悪い!
leko
1
350
Other Decks in Programming
See All in Programming
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
820
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
150
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
540
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
1.4k
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
140
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
5.4k
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
190
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
4.2k
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
120
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.3k
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
200
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
320
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
160
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
WCS-LA-2024
lcolladotor
0
510
Skip the Path - Find Your Career Trail
mkilby
1
93
A Tale of Four Properties
chriscoyier
163
24k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Site-Speed That Sticks
csswizardry
13
1.1k
Between Models and Reality
mayunak
3
250
Transcript
LT: IntersectionObserverはいいぞ @L_e_k_o
しごと 「CureApp禁煙」という治療アプリの開発 しゅみ プログラミング、トレラン、射撃 きになる react-native-web、OpenAPI(v3)、Almin L_e_k_o Leko れこ
Copyright CureApp, Inc. All Rights Reserved.
Scroll event なるべく頑張りたくない
• 画像の遅延ロード • 無限スクロール • スクロールスパイ(例:Googleのブログ) • 一定のスクロール位置からposition: fixed •
Adのインプレッション計測 • 視差効果・パララックス Scroll eventよくある処理
• scrollイベントの負荷を減らす - Qiita • Webフロントエンドに従事するお前らはいい加減高頻度イベン トとレイアウトとスタイリングの付き合い方を考えろ - Qiita •
JavaScriptでの多発するイベントの間引き処理 | 技術コラム | つみきブログ Scroll eventよくあるTips
$(window).on(‘scroll’, throttle(e => …) ) IntersectionObserver
IntersectionObserver The Intersection Observer API provides a way to asynchronously
observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. Intersection Observer API - Web APIs | MDN
Forced Synchronous Layout その時点での DOM の位置を取得するために Layout 計算を行う。 この計算は同期処理であり、つまりブロックが発生する。さらにそれを onscroll
など頻度 の高いイベントの中で行うのは、スムーズなスクロール表示のためのブラウザの最適化を 阻害してしまう。 - Intersection Observer を用いた要素出現検出の最適化 | blog.jxck.io
やや先読み遅延ロード https://codepen.io/L_e_k_o/details/JroVxy
56行でスター1600
threshold + intersectionRatio https://codepen.io/L_e_k_o/details/Ewazyb
消えたらfixed、見えたらstatic https://codepen.io/L_e_k_o/details/OxPYay/
polyfill:w3c/IntersectionObserver
• 見えてる/見えない = entry.isIntersecting • どれくらい先読みするか = options.rootMargin • どれくらい見えてるか
= entry.intersectionRatio • 見えてる間のイベント発生頻度 = options.threshold 正確ではないまとめ
IntersectionObserverはいいぞ More details: Intersection Observer API - Web APIs |
MDN IntersectionObserver/explainer.md at master · w3c/IntersectionObserver Intersection Observer を用いた要素出現検出の最適化 | blog.jxck.io openfresh/viewport-observer (React) 96 line heavyy/vue-intersect (Vue)