Giter Site home page Giter Site logo

brayancruces / scrollbear Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chenghaoc/scrollbear

0.0 1.0 0.0 1.76 MB

A modern tool that maintains scroll position when images loaded

Home Page: http://changbenny.github.io/scrollbear/

License: MIT License

JavaScript 33.95% HTML 66.05%

scrollbear's Introduction

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.

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()

Development

npm install
gulp

Contribute

Issues or PR are all Welcome!

License

MIT

scrollbear's People

Contributors

chenghaoc avatar

Watchers

Brayan Cruces avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.