Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
IntersectionObserverはいいぞ
Search
Leko
September 15, 2017
Programming
3.3k
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
72
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
3
410
エンジニアと治療アプリ®
leko
0
1.4k
Node.jsにContributeして一ヶ月でCollaboratorになった
leko
5
7.7k
React NativeアプリでE2Eテストを回してみた
leko
8
3k
React Nativeで医療機器作ってます
leko
4
1.8k
趣味では使っているが 仕事には使ってないツール
leko
1
260
レガシーな開発現場にUTを入れてCIを導入した話
leko
0
6.5k
MySQLがゆるふわなのはどう考えてもSQLモードが悪い!
leko
1
370
Other Decks in Programming
See All in Programming
R8 の設定見直しでアプリサイズ削減
andpad
0
160
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
390
phperだってパンチカードでコーディングしたい
o0h
PRO
0
210
Workers Cache を知る
syumai
0
340
FreeBSDでZabbixを動かす
kenkino
0
360
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
100
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.9k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
340
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
270
すこし踏み込む CancellationToken
htkym
2
1.6k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
370
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
550
How to Talk to Developers About Accessibility
jct
2
560
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Crafting Experiences
bethany
1
370
For a Future-Friendly Web
brad_frost
183
10k
Become a Pro
speakerdeck
PRO
31
6.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.3k
Ruling the World: When Life Gets Gamed
codingconduct
0
390
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)