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
3k
IntersectionObserverはいいぞ
IntersectionObserverを使っていただきたいだけの話
Leko
September 15, 2017
Tweet
Share
More Decks by Leko
See All by Leko
エンジニアと治療アプリ®
leko
0
1.1k
Node.jsにContributeして一ヶ月でCollaboratorになった
leko
5
7.2k
React NativeアプリでE2Eテストを回してみた
leko
8
2.8k
React Nativeで医療機器作ってます
leko
4
1.7k
趣味では使っているが 仕事には使ってないツール
leko
1
210
レガシーな開発現場にUTを入れてCIを導入した話
leko
0
6.2k
MySQLがゆるふわなのはどう考えてもSQLモードが悪い!
leko
1
300
Other Decks in Programming
See All in Programming
아직도 SOLID 를 '글'로만 알고 계신가요?
sh1mj1
0
360
OpenTelemetryを活用したObservability入門 / Introduction to Observability with OpenTelemetry
seike460
PRO
1
370
Defying Front-End Inertia: Inertia.js on Rails
skryukov
0
340
Signal-Based Data FetchingWith the New httpResource
manfredsteyer
PRO
0
110
JavaOne 2025: Advancing Java Profiling
jbachorik
1
320
Go1.24 go vetとtestsアナライザ
kuro_kurorrr
2
700
AI Agents with JavaScript
slobodan
0
180
Productivity is Messing Around and Having Fun
hollycummins
0
160
新卒から4年間、20年もののWebサービスと 向き合って学んだソフトウェア考古学
oguri
8
7k
Agentic Applications with Symfony
el_stoffel
1
150
Coding Experience Cpp vs Csharp - meetup app osaka@9
harukasao
0
470
PHPのガベージコレクションを深掘りしよう
rinchoku
0
250
Featured
See All Featured
Writing Fast Ruby
sferik
628
61k
KATA
mclloyd
29
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
51
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Embracing the Ebb and Flow
colly
85
4.6k
The Cult of Friendly URLs
andyhume
78
6.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
177
52k
Optimising Largest Contentful Paint
csswizardry
35
3.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Building Applications with DynamoDB
mza
94
6.3k
Faster Mobile Websites
deanohume
306
31k
Designing Experiences People Love
moore
141
23k
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)