Skip to content
프로젝트

소개

요소가 뷰포트에 들어오는 시점을 감지하는 종속성 없는 JavaScript 라이브러리입니다.

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

enter-view

Dependency-free JavaScript library to detect when element enters into view. See demo. It uses requestAnimationFrame in favor of scroll events for less jank. Less than 1kb minified + gzipped.

Installation

Old school (exposes the enterView global):

<script src="https://unpkg.com/enter-view"></script>

New school:

npm install enter-view --save

And then import/require it:

import enterView from 'enter-view'; // or...
const enterView = require('enterView');

Usage

enterView({
	selector: '.class-name',
	enter: function(el) {
		el.classList.add('entered');
	}
});
enterView({
	selector: '.class-name',
	enter: function(el) {
		el.classList.add('entered');
	},
	exit: function(el) {
		el.classList.remove('entered');
	},
	progress: function(el, progress) {
		el.style.opacity = progress;
	},
	offset: 0.5, // enter at middle of viewport
	once: true, // trigger just once
});

Options

selector: [string or array of elements] required

Takes a class, id, or array of dom elements.

enter: [function] optional

Callback function that returns the element that was entered.

exit: [function] optional

Callback function that returns the element that was exited.

progress: [function] optional

Callback function that returns the element that was progressed through, and a value between 0 and 1 of how far through the element progress has been made.

offset: [number] optional (defaults to 0)

A value from 0 to 1 of how far from the bottom of the viewport to offset the trigger by. 0 = top of element crosses bottom of viewport (enters screen from bottom), 1 = top of element crosses top of viewport (exits screen top).

once: [boolean] optional (defaults to false)

Whether or not to trigger the callback just once.

Contributors

관련 프로젝트 살펴보기

불러오는 중…