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
Transcript
15 slides
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)
More Decks by Leko
See All by Leko
コンセプトの海の泳ぎ方
leko
0
77
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
3
430
エンジニアと治療アプリ®
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
270
レガシーな開発現場にUTを入れてCIを導入した話
leko
0
6.5k
MySQLがゆるふわなのはどう考えてもSQLモードが悪い!
leko
1
380
Other Decks in Programming
See All in Programming
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.3k
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
380
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
250
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
200
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
160
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
150
Crash Auto Pipelines
veronikapj
1
410
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
150
LLM 101
dalinaum
0
490
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
2
370
Scalaの型でマルチテナントの認可を守る
nextbeatdev
0
110
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
400
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Optimising Largest Contentful Paint
csswizardry
37
4k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
830
Making the Leap to Tech Lead
cromwellryan
135
10k
What the history of the web can teach us about the future of AI
inesmontani
PRO
3
810
Thoughts on Productivity
jonyablonski
76
5.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
From π to Pie charts
rasagy
1
450
Tell your own story through comics
letsgokoyo
1
1.1k
Code Reviewing Like a Champion
maltzj
529
40k