chenghaoc/scrollbear
소개
이미지가 로드될 때 스크롤 위치를 유지하는 최신 도구입니다.
디자인 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -2
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalScrollbear
Scrollbear is a tool that maintains the container scroll position when images loaded. Scrollbear is suitable in blog platforms where exist many photos and images. When images loaded, the scroll position will jump and cause a unfriendly experience. Scrollbear will trace the container height and maintain the scroll position when the images loaded and container height change.
** Since Google Chrome launch scolling anchor feature, there's no difference with or without Scrollbear in Chrome browser.
Demo
Installation
npm install scrollbear
Usage
<div id='scroll' style='overflow: scroll;'>
<div id='container'>
<p>long content</p>
<p>long content</p>
</div>
</div>
<script src='scrollbear.js'></script>
Scrollbear.start(document.getElementById('scroll'))
API
Scrollbear.start(target, [changedItems])
target is the DOM where scroll bar exists (Normally is the container of contents), normally the direct child node of this target will be a DOM with really long content (such as the content of blog articles).
changeItems is optional. It is useful when images is lazy loading into your page. In such case, you can specify the placeholder of images. When images is lazy-loaded, the height of placeholder will change, and trigger the Scrollbear to justify the scroll position.
Scrollbear.stop()
Scrollbear.onChange(callback)
callback function will be called when Scrollbear detects container height changes and adjust the scroll position. The first param of callback will be the target which height changed.
Development
Install development dependency
npm install
Build
gulp
Test
npm test
Contribute
Issues or PR are all Welcome!
License
MIT
관련 프로젝트 살펴보기
불러오는 중…