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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
IntersectionObserverはいいぞ
IntersectionObserverを使っていただきたいだけの話
Leko
September 15, 2017
More Decks by Leko
See All by Leko
コンセプトの海の泳ぎ方
leko
0
55
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
3
380
エンジニアと治療アプリ®
leko
0
1.3k
Node.jsにContributeして一ヶ月でCollaboratorになった
leko
5
7.6k
React NativeアプリでE2Eテストを回してみた
leko
8
3k
React Nativeで医療機器作ってます
leko
4
1.8k
趣味では使っているが 仕事には使ってないツール
leko
1
250
レガシーな開発現場にUTを入れてCIを導入した話
leko
0
6.5k
MySQLがゆるふわなのはどう考えてもSQLモードが悪い!
leko
1
360
Other Decks in Programming
See All in Programming
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
100
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
160
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
160
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
dRuby over BLE
makicamel
2
330
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.1k
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4k
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
Featured
See All Featured
From π to Pie charts
rasagy
0
210
Why Our Code Smells
bkeepers
PRO
340
58k
Google's AI Overviews - The New Search
badams
0
1k
Paper Plane (Part 1)
katiecoart
PRO
0
8.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
470
HDC tutorial
michielstock
2
700
Accessibility Awareness
sabderemane
1
140
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
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)