A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars.

Overview

This project is not maintained

This project is not currently actively maintained. If you need an up-to-date scrollbar plugin, try OverlayScrollbars instead: https://github.com/KingSora/OverlayScrollbars

nanoScroller.js NPM version

nanoScroller.js is a jQuery plugin that offers a simple way of implementing Mac OS X Lion-styled scrollbars for your website. It uses minimal HTML markup being .nano > .nano-content. The other scrollbar div elements .pane > .nano-slider are added during run time to prevent clutter in templating. The latest version utilizes native scrolling and works with the iPad, iPhone, and some Android Tablets.

Downloads

To start using, you need three basic things:

1. Markup

The following type of markup structure is needed to make the plugin work:

<div id="about" class="nano">
    <div class="nano-content"> ... content here ...  </div>
</div>

Copy the HTML markup. Change .nano into something related to your content. Though you can also remove that attribute as long as you have a parent div with an ID reference. e.g. #parent > .nano. nano and nano-content classnames can be customized via plugin options (in that case you must rename them inside the plugin's CSS file as well).

2. CSS

Link to the nanoscroller.css file inside your page's <head> section (...or copy the contents from it to your page's main stylesheet file).

<link rel="stylesheet" href="nanoscroller.css">

You should specify a width and a height to your container, and apply some custom styling for your scrollbar. Here's an example:

.nano { background: #bba; width: 500px; height: 500px; }
.nano > .nano-content { padding: 10px; }
.nano > .nano-pane   { background: #888; }
.nano > .nano-pane > .nano-slider { background: #111; }

3. JavaScript

Running this script will apply the nanoScroller plugin to all DOM elements with a .nano className.

$(".nano").nanoScroller();

Advanced methods

scroll

To scroll at the top:

$(".nano").nanoScroller({ scroll: 'top' });

To scroll at the bottom:

$(".nano").nanoScroller({ scroll: 'bottom' });

To scroll at the top with an offset value:

$(".nano").nanoScroller({ scrollTop: value });

To scroll at the bottom with an offset value:

$(".nano").nanoScroller({ scrollBottom: value });

To scroll to an element:

$(".nano").nanoScroller({ scrollTo: $('#a_node') });

stop:

To stop the operation. This option will tell the plugin to disable all event bindings and hide the gadget scrollbar from the UI.

$(".nano").nanoScroller({ stop: true });

destroy:

Destroys nanoScroller and restores browser's native scrollbar.

$(".nano").nanoScroller({ destroy: true });

flash:

To flash the scrollbar gadget for an amount of time defined in plugin settings (defaults to 1,5s). Useful if you want to show the user (e.g. on pageload) that there is more content waiting for him.

$(".nano").nanoScroller({ flash: true });

nanoScroller();

Refresh the scrollbar. This simply re-calculates the position and height of the scrollbar gadget.

$(".nano").nanoScroller();

Custom events

'scrollend'

A custom 'scrollend' event is triggered on the element every time the user has scrolled to the end of the content element (does not get triggered more than once when user tries to scroll down and has already reached the end of scrollable content).

$(".nano").bind("scrollend", function(e){
    console.log("current HTMLDivElement", e.currentTarget);
});

Some browsers trigger this event more than once each time, so to listen to the custom event, instead of using jQuery's normal .bind or .on, you most likely want to use this tiny jQuery debounce plugin to prevent browsers from firing your function more than once every 100ms.

$(".nano").debounce("scrollend", function() {
    alert("The end");
}, 100);

'scrolltop'

Same as the 'scrollend' event, but it is triggered every time the user has scrolled to the top of the content element.

'update'

Same as the 'scrolltop' and 'scrollend' events, but it's triggered every time the user scrolls. It also carries a JavaScript object with the current position, the maximum height and the direction (up or down).

$(".nano").on("update", function(event, values){
    console.debug( values );
});

Plugin Options

There are a few options that you can change when running nanoScroller, e.g. $(".nano").nanoScroller({ paneClass: 'myclass' });

iOSNativeScrolling

Set to true if you want to use native scrolling in iOS 5+. This will disable your custom nanoScroller scrollbar in iOS 5+ and use the native one instead. While the native iOS scrollbar usually works much better, there could possibly be bugs in certain situations.

Notice that .pane and .slider elements are not generated/added for devices that support iOS native scrolling when iOSNativeScrolling option is enabled.

Default: false

$(".nano").nanoScroller({ iOSNativeScrolling: true });

sliderMinHeight

Sets the minimum height of the slider element.

Default: 20

$(".nano").nanoScroller({ sliderMinHeight: 40 });

sliderMaxHeight

Sets the maximum height of the slider element.

Default: null

$(".nano").nanoScroller({ sliderMaxHeight: 200 });

preventPageScrolling

Set to true to prevent page scrolling when top or bottom inside the content div is reached.

Default: false

$(".nano").nanoScroller({ preventPageScrolling: true });

disableResize

Set to true to disable the resize from nanoscroller. Useful if you want total control of the resize event. If you set this option to true remember to call the reset method so that the scroll don't have strange behavior.

Default: false

$(".nano").nanoScroller({ disableResize: true });

alwaysVisible

Set to true to stop the scrollbar from auto-hiding itself.

Default: false

$(".nano").nanoScroller({ alwaysVisible: true });

flashDelay:

Use this setting to specify the scrollbar hide delay in milliseconds if you have enabled the flash option.

$(".nano").nanoScroller({ flashDelay: 1000 });

Default: 1500

paneClass

A classname for scrollbar track element. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'nano-pane'

$(".nano").nanoScroller({ paneClass: 'scrollPane' });

sliderClass

A classname for scrollbar thumb element. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'nano-slider'

$(".nano").nanoScroller({ sliderClass: 'scrollSlider' });

contentClass

A classname for your content div. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'nano-content'

$(".nano").nanoScroller({ contentClass: 'sliderContent' });

enabledClass

A classname for scrollbar enabled mode. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'has-scrollbar'

$(".nano").nanoScroller({ enabledClass: '__enabled' });

flashedClass

A classname for scrollbar flashed mode. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'flashed'

$(".nano").nanoScroller({ flashedClass: '__flashed' });

activeClass

A classname for scrollbar active mode. If you change this setting, you also have to change it in the plugin's CSS file.

Default: 'active'

$(".nano").nanoScroller({ activeClass: '__active' });

tabIndex

Set the tab order of the scrollable content. Set to -1 to skip over the scrollable content when tabbing.

Default: 0

$(".nano").nanoScroller({ tabIndex: 0 });

How it works

Fig 1.

The plugin works by creating a scrollbar gadget (with pre-defined css for styling) and then subscribing the .nano-content's scroll events to it. Mouse press and drag events are also subscribed to the .nano-pane and .nano-pane > .nano-slider to emulate the native scrollbar's mechanism. The system scrollbars are hidden from the viewport (Fig 1). By doing this, we still retain the natural scrolling experience provided by the OS.

We are still working on doing a horizontal scrolling feature. If you're interested in contributing to the project, you are free to fork it and create a pull request.

Development

To build nanoScroller from source you need the following libraries installed:

How to build & contribute

  1. Make sure that you have Grunt installed.
  2. In terminal move to nanoscroller folder and run npm install to install all dependencies.
  3. Make all Javascript changes in Coffeescript file(s), CSS changes in CSS file(s).
  4. run grunt to build nanoScroller
  5. Make sure that all changes are valid and open a pull request.

How to run tests

  1. You need to have PhantomJS installed. On Mac OS X the easiest way is to install Homebrew and run brew install phantomjs.
  2. run grunt test in terminal

Browser compatibility

Tested desktop browsers:

  • IE7+
  • Firefox 3+
  • Chrome
  • Safari 4+
  • Opera 11.60+

Mobile support:

  • iOS 5+ (iPhone, iPad and iPod Touch)
  • iOS 4 (with a polyfill)
  • Android Firefox
  • Android 2.2/2.3 native browser (with a polyfill)
  • Android Opera 11.6 (with a polyfill)
  • If you see it's broken on other tablets and mobile devices, please file a ticket in the git repo. Along with model name, and OS of the device.

If you find a bug, please report here at the issues section.

Using a polyfill for better mobile browser support

You can use overthrow.js polyfill (~1.5kb minified and gzipped) to make nanoScroller work on many mobile devices. It emulates CSS overflow (overflow: auto;/overflow: scroll;) in devices that are lacking it.

To use overthrow, link to the javascript file in your HTML document...

<script src="overthrow.js"></script>

...and add an overthrow class to your content div.

<div id="about" class="nano">
    <div class="overthrow nano-content"> ... content here ...  </div>
</div>

Contributors

Other people who have contributed code:

Credits

Comments
  • Native Scrollbar Padding Visible in Chrome 37 Mac OS X

    Native Scrollbar Padding Visible in Chrome 37 Mac OS X

    Today Chrome updated me to Chrome 37 and I found that nanoscroller containers were showing a space where the original scrollbar should appear.

    Here is Chrome 36 vs Chrome 37:

    example

    It seems that

    .nano > .nano-content::-webkit-scrollbar {
      visibility: hidden;
    }
    

    Doesn't totally remove the scroll bar in version 37+ on Mac OS X (and is still the case in the latest Canary build). This doesn't seem to affect Windows.

    I was able to fix it by adding

    width: 0px;
    

    To the above CSS class.

    Bug Browser bug 
    opened by andyvenus 26
  • Move slider on keypress

    Move slider on keypress

    I've changed it to use e.which like you suggested. The changes I made seem to fix the problem well. Let me know if you can think of anything else which could be changed. Thanks!

    opened by rickihastings 25
  • JS Error ( line 215 )

    JS Error ( line 215 )

    I get a weird js error in console and the scrollbar doesn't work at all. It says I have an error in your script at line 215 :

    contentStyle = content.style;
    

    The above would be the line, Additional info, it also says that it cannot read the property "style" of undefined. So what can I do about that ?

    opened by rolandjitsu 25
  • Added horizontal scrolling feature

    Added horizontal scrolling feature

    Added support for horizontal slider. Now you can use both sliders at the same time or just one (horizontal or vertical)

    View the demo

    Related issue: https://github.com/jamesflorentino/nanoScrollerJS/issues/14

    I hope you like this pull request! ;)

    Pull request 
    opened by syrusakbary 23
  • scroll executes previous event

    scroll executes previous event

    When i scroll down once it doesnt slide the slider down. When i scroll down a second time it scrolls down to the position i was before the scroll.

    My guess is that it executes the previous event.

    Bug 
    opened by marcvdm 20
  • Scroller disappears in tab menu

    Scroller disappears in tab menu

    I successfully embed the scroller in my mega menu which has tabbed sections in it. To my surprise I can only have one nanoscroller at a time and the other aren't visible at all nor are they present (when checked with firebug)

    Is this a bug or an issue that can be resolved? I can provided an example in private though.

    SOme help will be greatly appreciated, thanks.

    opened by benzine 18
  • Bug with scrollTo : $(element)

    Bug with scrollTo : $(element)

    Hi,

    I don't know if there's a problem with the scrollTo method, or if I don't know how to use it.

    When I use it for the first time it's ok, but when I try to use it again, doesn't work as espected.

    The scrollTop, scrollBottom and scroll options works fine every time.

    Try to go to #30 (or other) and then back to #1 with the first button to see what I'm talking about in this fiddle http://jsfiddle.net/YZVXL/4/

    Bug 
    opened by ghost 17
  • Initializing with the `scrollTop` option, the scroll slider sometimes doesn't move to the correct position.

    Initializing with the `scrollTop` option, the scroll slider sometimes doesn't move to the correct position.

    There seems to be a bug with using the scrollTop and the positioning of the scroll slider. I've got a blog with a scrollable navigation list. I set a class on one of the nav items of 'here' for the page that the user is currently looking at, and then use some javascript to scroll the div to the correct point using the following:

    $(function () {
       var value = $('.here').position().top - (300 / 2) + ($('nav ul li:first').height() / 2);
       $(".nano").nanoScroller({scrollTop: value});
    });
    

    The nanoscroller works, and the nav element is scrolled to the correct place. However, the nanoscroll slider is at the top, as opposed to being some way down.

    I've put a jsfiddle here http://jsfiddle.net/Gea5T/1/

    Mouse scrolling mades the slider jump to the correct place, and grabbing the slider jumps the nav scroll position back to the top.

    Bug 
    opened by growse 15
  • Hide scrollbar after scroll event has finished, even if mouse is still over the div.

    Hide scrollbar after scroll event has finished, even if mouse is still over the div.

    Great plugin, thanks for it! Works a charm for my project.

    With Facebooks scroll bars and Mac OS X Lion scroll bars the bar fades out after the scroll event has finished even if the mouse is still hovering over the element. I think this would be a good feature to add to this plug in.

    Feature request 
    opened by jamcoupe 14
  • chrome there is a height issue with lastest chrome

    chrome there is a height issue with lastest chrome

    to replicate.... load page... with a div that has been nano..ed and note the height of the scroll bar... then move the window.. browser window... a fraction and note the scroll height.... please could you fix this...

    when the browser window has been moved a faction the scroll height is corrected.

    Bug 
    opened by Seabizkit 13
  • Bug Report - Android / Cyanogenmod 7.0.3 (Desire) and Desire HD

    Bug Report - Android / Cyanogenmod 7.0.3 (Desire) and Desire HD

    On Android version 2.3.3, native browser, nanoScroller is not working.

    When tapping with the finger on the scrollable area, slider and pane appeared on the right side of div. Then, when sliding the screen with a finger, the page moving up or down completely, not just the scrollable part of the page.

    Browser compatibility 
    opened by ibalpinar 13
  • Unable add nano scroll on body element?

    Unable add nano scroll on body element?

    I want ro add nano scroll on body element. But as per the docs, the structure should be <div class="nano"><div class="nano-content"></div></div>

    then how to add nano scroll on body element?

    opened by Ram-SR 1
  • Top attribute on parent container shortens scroller

    Top attribute on parent container shortens scroller

    Hi all,

    Sorry for the terrible description but this one is pretty tricky to articulate.

    I have a scrollable section with a fixed position and a top of 80px to push it down a bit. I believe that this is shortening the scrollable area by 80px. Is there some way I can compensate for this?

    Cheers,

    opened by silentFred 1
  • Prevents click events on Windows 8

    Prevents click events on Windows 8

    When using this on Windows 8, I have noticed that any elements within the scrollable panel that have click events attached to them are ignored. I presume because on touchstart you are calling something to prevents any further events bubbling up. Is there a way to stop this?

    Bug needs to be verified 
    opened by iamdriz 1
Releases(0.8.6)
  • 0.8.6(Apr 11, 2015)

    Thanks to our awesome contributors for this release!

    Changes:

    • Fixed relative path for css dependency in package.json (@scoarescoare, https://github.com/jamesflorentino/nanoScrollerJS/pull/284)
    • Use !default in sass variables (@guzart, https://github.com/jamesflorentino/nanoScrollerJS/pull/287)
    • Fix case where height of scrollWindow does not equal height of scrollTrack (issue #244) (@erikhagreis, https://github.com/jamesflorentino/nanoScrollerJS/pull/290)
    • Cleanup package.json (to release nanoScroller to npm) (@SimenB, https://github.com/jamesflorentino/nanoScrollerJS/pull/292)
    • Add UMD wrapper (@SimenB, https://github.com/jamesflorentino/nanoScrollerJS/pull/293)
    Source code(tar.gz)
    Source code(zip)
  • 0.8.5(Mar 5, 2015)

    Changes:

    • Added AMD Wrapper #267, fixes #266
    • Bug fix: use @options instead of options #281
    • Added jspm/jspm config settings #283
    • Small readme fixes #277
    • Fix classnames in unit tests #257
    Source code(tar.gz)
    Source code(zip)
  • 0.8.2(Aug 29, 2014)

  • 0.8.0(Mar 6, 2014)

    ! This release contains a breaking change! nanoScroller's CSS classes have been renamed like this: .content => .nano-content, .pane => .nano-pane and .slider => .nano-slider. Please update your JS, CSS and HTML when using the latest version.

    Changelog:

    • allow relative and static position to be used for .nano-content, #207
    • fix slider not updating when calling scrollTop and scrollBottom #216, #205
    • highlight code in README, #220
    • avoid common CSS classnames by renaming classes in nanoscroller and docs. Use CSS direct child selector, #146, #208, #214
    • scrollTo now finds the elements from its children, #197
    • set this.scrollRAF to null, #202
    • fixed scrollBottom and scrollTop when the value was 0, #201

    Thanks to all contributors!

    Source code(tar.gz)
    Source code(zip)
  • 0.7.6(Nov 10, 2013)

  • 0.7.5(Nov 3, 2013)

    Changes:

    • Hide Firefox 24+ native scrollbar.
    • Use requestAnimationFrame when scrolling.
    • Use CSS 2d transforms for scrollbar if browser supports them.
    • Fix some errors that were thrown when iOSNativeScrolling was used.
    Source code(tar.gz)
    Source code(zip)
This app offers users a quick way to check the current temperature and humidity of any location in the world.

Pretty Weather App This app offers users a quick way to check weather data for any location in the world. The specific data provided by the app includ

Benjamin Semah 3 Jun 7, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or enter your email address and more.

Demodal Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or en

Elbert Alias 225 Jan 4, 2023
Another logger in JS. This one offers a console.log-like API and formatting, colored lines and timestamps (or not if desired), all that with 0 dependencies.

hellog Your new logger ! hellog is a general-purpose logging library. It offers a console.log-like API and formatting, extensible type-safety colored

Maxence Lecanu 4 Jan 5, 2022
ArchiveWeb.page Express offers high-fidelity web archiving directly in the browser

ArchiveWeb.page Express offers high-fidelity web archiving directly in the browser! It provides a more streamlined version of ArchiveWeb.page system without requiring a custom extension or desktop app!

Webrecorder 5 Jul 21, 2022
A simple to-do list web application built with ES6 and bundled with webpack. Checkout the awesome features it offers.

A To-do List Web Application A simple to-do list with amazing features and a great ux. built using ES6 and npm webpack. Check it out to explore its am

Chia Carlyle 9 Apr 15, 2022
Awesome books is a vanilla Javascript which offers CRUD functionalities allowing you to add, remove edit boks info and store it to the local storage.

Awesome Books Awesome books is a simple project that displays new books when a user updates them. Built With HTML-5 CSS3 Javacript Linters Live Demo L

Nemwel Boniface 23 Aug 6, 2022
Omnichannel Live Chat Widget UI Components offers a re-usable component-based library to help create a custom chat widget that can be connected to the Dynamics 365 Customer Service experience.

Omnichannel Live Chat Widget UI Components @microsoft/omnichannel-chat-widget is a React-based UI component library which allows you to build your own

Microsoft 14 Dec 15, 2022
Weaver IBAX IDE. IBAX Network offers a polished development tool Weaver to develop DApps for ecoLibs (side chains).

Weaver Provide the user interface for ibax. Provide the IDE for App development. Save the private key of the user account and grant the permissions. R

IBAX PUBLIC NETWORK 51 Nov 4, 2022
The SheetJS Community Edition offers battle-tested open-source solution

The SheetJS Community Edition offers battle-tested open-source solutions for extracting useful data from almost any complex spreadsheet and generating new spreadsheets that will work with legacy and modern software alike.

SheetJS 32k Dec 29, 2022
Team Empire offers an innovative and intuitive game based on puzzles solved by two players working in a team.

Team Empire offers an innovative and intuitive game based on puzzles solved by two players working in a team. The user can create an account to monitor their results and achievements. The whole idea of the product is to make the player think and develop his logical thinking.

Vocational school for computer programming and innovation 14 Aug 8, 2022
A hub for web developers that offers a variety of tools to help with any developing needs.

WebDevHub - A place for developers WebDevHub is designed to be one central place for developers, that offers a variety of tools to help with any devel

Thomas Hamilton-Smith 87 Dec 11, 2022
Incredible drastically simplifies creation of developer video content. It offers a unified workflow to storyboard, record, collaborate and produce the video.

?? Introduction Incredible drastically simplifies creation of developer video content. It offers a unified workflow to storyboard, record, collaborate

Incredible 113 Dec 6, 2022
microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex - A catalog of RegEx patterns View Demo · Report Bug · Request Feature Loved the tool? Please consider contributing ✍️ to help it improve!

Sunit Shirke 4 Oct 25, 2022
Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components.

Chakra UI Animations Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components. Installation yarn add @

Code Chemistry Inc. 9 Nov 19, 2022
Example project implementing authentication, authorization, and routing with Next.js and Supabase

Magic Link Authentication and Route Controls with Supabase and Next.js To run this project, To get started with this project, first create a new proje

Nader Dabit 134 Dec 11, 2022
Implementing hexagonal architecture on AWS Lambda with Node.js

Developing evolutionary architecture with AWS Lambda Context Agility enables you to evolve a workload quickly, adding new features, or introducing new

AWS Samples 95 Dec 20, 2022
Venni backend - The backend of the Venni client apps implementing the credit card payments, matching algorithms, bank transfers, trip rating system, and more.

Cloud Functions Description This repository contains the cloud functions used in the Firebase backend of the Venni apps. Local Development Setup For t

Abrantes 1 Jan 3, 2022