Giter Club home page Giter Club logo

scroll-up-bar's Introduction

ScrollUpBar Plugin

The scroll up bar plugin (jQuery) hides the top bar when scrolling down, and show it when scrolling up. It's specially useful on mobile interfaces to save some precious space.

Demos

Installation

Include jQuery and scroll-up-bar.min.js scripts:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="scroll-up-bar.min.js"></script>

Bower users can get the source with:

bower install scroll-up-bar

Basic Usage

Create a top bar using position absolute.

<div id="topbar" style="position: absolute; top: 0; left: 0; width: 100%; background: #ccc;">
  Top bar
</div>

Tip: you can also add top different than zero

And then invoke scrollupbar() on the element.

$('#topbar').scrollupbar();

Alternatively you can invoke with $.scrollupbar($('#topbar'))

Options

You can pass callback functions in initialization to handle bar visibility events.

  • enterViewport - when the bar enters the viewport
  • fullyEnterViewport - when the bar is completely in the viewport
  • exitViewport - when the bar completely leaves the viewport
  • partiallyExitViewport - when the bar goes from being fully in the viewport to only partially

Checkout the callback example.

Properties

There are two global boolean properties that are updated according to bar visibility.

  • $.scrollupbar.isInViewport - true if any part of the bar is visible, false if not
  • $.scrollupbar.isFullyInViewport - true if the entire bar is visible

Methods

  • $.scrollupbar.destroy - restores bar to original position and disables plugin

Browser support

The plugin was tested on:

  • Chrome
  • Firefox
  • Safari
  • Opera
  • IE

Contributing

Read the Contributing document for instructions on how to set up your development environment to build and test scroll-up-bar.

scroll-up-bar's People

Contributors

eduardomb avatar wsh9000 avatar uvisgrinfelds avatar

Watchers

pwoot 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.