분류
javascript
스크롤 할 때 요소를 모니터 하는 간단하고 빠른 API
본문
https://github.com/stutrek/scrollMonitor
스크롤 모니터를 사용하면 요소가 뷰포트에 들어가거나 나올 때 이벤트를 수신 할 수 있습니다.
var scrollMonitor = require("scrollmonitor"); // if you're old school you can use the scrollMonitor global. var myElement = document.getElementById("itemToWatch"); var elementWatcher = scrollMonitor.create( myElement ); elementWatcher.enterViewport(function() { console.log( 'I have entered the viewport' ); }); elementWatcher.exitViewport(function() { console.log( 'I have left the viewport' ); });
- 이전글웹 개발자를 위한 스크립트 가능한 브라우저 19.04.11
- 다음글브라우저 검출기 19.04.11