javascript-tutorial / javascript-tutorial/en.javascript.info
Intersection Observer API
まだ誰も着手していません。
- 主要言語
- HTML
- スター
- 25.5k
- フォーク
- 4k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hey!
Would be nice to see a topic about the Intersection Observer API: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
I used it one time, where I made a navbar sticky, whenever the user scrolling down and the hero section is no longer in the viewport. Example:
function stickyHeaderHandling() {
const sectionHero = document.getElementById("hero-section");
const navHeader = document.getElementById("nav-header");
const stickyNav = function (entries) {
const [entry] = entries;
if (!entry.isIntersecting) {
navHeader.classList.add("sticky--header");
} else {
navHeader.classList.remove("sticky--header");
}
};
const heroObserver = new IntersectionObserver(stickyNav, {
root: null,
threshold: 0.1,
});
heroObserver.observe(sectionHero);
}
Also you can use it for lazy loading images, or animate html elements whenever the elements get into the viewport(https://www.itzami.com/blog/boost-your-css-animations-with-intersection-observer-api).
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている MDN の Intersection Observer API ページを出発点となるリファレンスとして使用してください。提供されている sticky navbar の例を確認し、提案されている lazy-loading と viewport によってトリガーされるアニメーションのユースケースを検討してください。完了条件は、範囲が定義され、Intersection Observer API の例を含む完全なチュートリアルのトピックが作成されていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- documentation, web-dev
- issue の種類
- ドキュメント
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100