Skip to content

Commit

Permalink
Revised README and IE6 fix
Browse files Browse the repository at this point in the history
A more complete README file, with some examples and a list of custom parameters.
IE6 fix
  • Loading branch information
inuyaksa committed Nov 2, 2011
1 parent 5eb0ace commit 245d9b7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 39 deletions.
1 change: 0 additions & 1 deletion MIT.LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Open Source Initiative OSI - The MIT License (MIT):Licensing
[OSI Approved License]
The MIT License (MIT)

jQuery NiceScroll
Copyright (c) 2011 InuYaksa

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
57 changes: 49 additions & 8 deletions README
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
jquery.nicescroll
v. 1.5.0 10-30-2011
v. 1.5.1 10-30-2011
copyright 2011 InuYaksa*2011
licensed under the MIT
https://github.com/inuyaksa/jquery.nicescroll


A jquery (since 1.5) plugin for nice scrollbars as ios/mobile style.
Nicescroll (as nice scroll for browsers) is a jquery (since 1.5) plugin, for nice scrollbars with a very similar ios/mobile style.
It supports DIVs, IFrames and document page (body) scrollbars.
Compatible with Firefox 4+, Chrome 5+, Safari 4+, Opera 10+, IE 8+.
Compatible with Firefox 4+, Chrome 5+, Safari 4+ (win/mac), Opera 10+, IE 6+. (all A-grade browsers)

Only vertical scrolls supported in this version.
Only vertical scrollbars supported in this version.

Warning for IE6 users (who uses IE6 yet? Please updgrade to a more stable and modern browser), some feature can't work for limitation of the browser.
Document (body) scrollbars can't appears, old (native browser) one is used.
Some issues with IFrame scrolling.


1. How to use (simple):
* DEPENDENCIES
It uses jquery framework, since 1.5.x version. (you can try with 1.4.x)


* INSTALLATION
Put loading script tag after jquery script tag:

<script src="jquery.nicescroll.js"></script>


* HOW TO USE

Recall ALWAYS in (document) ready statement.

1. Simple mode, it styles document scrollbar:

$(document).ready(
function() {
$("body").niceScroll();
}
);



2. How to use (with object returned):
2. Style scrollbars wit object returned:

var scrollbars = false;
$(document).ready(
Expand All @@ -32,3 +47,29 @@ $(document).ready(
}
);

3. Style a DIV and chage cursor color:

$(document).ready(
function() {
$("#thisdiv").niceScroll({cursorcolor:"#00F"});
}
);


* CONFIGURATION PARAMETERS

When you call "niceScroll" you can pass some parameters to custom visual aspects:

. cursorcolor - change cursor color in hex, default is "#000000"
. cursoropacitymin - change opacity very cursor is inactive (scrollabar "hidden" state), range from 1 to 0, default is 0 (hidden)
. cursoropacitymax - change opacity very cursor is active (scrollabar "visible" state), range from 1 to 0, default is 1 (full opacity)
. zindex - change z-index for scrollbar div, default value is 9999
. scrollspeed - scrolling speed, default value is 60
. mousescrollstep - scrolling speed with mouse wheel, default value is 48 (pixel)


* LICENSE

Copyright 2011*InuYaksa
Licensed under the MIT License, http://www.opensource.org/licenses/mit-license.php

21 changes: 6 additions & 15 deletions demo/js/jquery.nicescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
cursoropacitymax:1,
cursorcolor:"#424242",
scrollspeed:60,
mousescrollstep:8*6,
mousescrollstep:8*6
};

if (myopt) {
if (myopt||false) {
for(var a in self.opt) {
if (myopt[a]!==undefined) self.opt[a] = myopt[a];
}
Expand Down Expand Up @@ -168,7 +168,7 @@
if (!self.rail.drag) self.hideCursor();
});

if (!self.isiframe) self.bind(self.docscroll,"mousewheel",self.onmousewheel);
if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
self.bind(self.rail,"mousewheel",self.onmousewheel);

if (!self.ispage) {
Expand Down Expand Up @@ -305,7 +305,7 @@
if (name=='mousewheel') el.addEventListener("DOMMouseScroll",fn,bubble||false);
}
else if (el.attachEvent) {
el.attachEvent(name,fn);
el.attachEvent("on"+name,fn);
}
else {
el["on"+name] = fn;
Expand Down Expand Up @@ -333,15 +333,6 @@
return self.cancelEvent(e);
};

this.mousewheel = function(fn) {
if (!self.isie) self.bind(self.docscroll,'DOMMouseScroll',self.onmousewheel,false);
self.bind(self.docscroll,'mousewheel',self.onmousewheel,false);
if (!self.ispage) {
if (!self.isie) self.bind(self.rail,'DOMMouseScroll',self.onmousewheel,false);
self.bind(self.rail,'mousewheel',self.onmousewheel,false);
}
};

this.doScroll = function(y) {
self.newscrolly = y;
if (self.timer) return;
Expand Down Expand Up @@ -402,8 +393,8 @@

$.fn.niceScroll = function(opt) {
var ret = [];
if (opt===undefined) opt = {};
var docundef = (opt.doc===undefined);
if (typeof opt=="undefined") opt = {};
var docundef = !("doc" in opt);
this.each(function() {
opt.doc = (docundef) ? $(this) : opt.doc;
ret.push(new NiceScrollClass(opt));
Expand Down
21 changes: 6 additions & 15 deletions jquery.nicescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
cursoropacitymax:1,
cursorcolor:"#424242",
scrollspeed:60,
mousescrollstep:8*6,
mousescrollstep:8*6
};

if (myopt) {
if (myopt||false) {
for(var a in self.opt) {
if (myopt[a]!==undefined) self.opt[a] = myopt[a];
}
Expand Down Expand Up @@ -168,7 +168,7 @@
if (!self.rail.drag) self.hideCursor();
});

if (!self.isiframe) self.bind(self.docscroll,"mousewheel",self.onmousewheel);
if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
self.bind(self.rail,"mousewheel",self.onmousewheel);

if (!self.ispage) {
Expand Down Expand Up @@ -305,7 +305,7 @@
if (name=='mousewheel') el.addEventListener("DOMMouseScroll",fn,bubble||false);
}
else if (el.attachEvent) {
el.attachEvent(name,fn);
el.attachEvent("on"+name,fn);
}
else {
el["on"+name] = fn;
Expand Down Expand Up @@ -333,15 +333,6 @@
return self.cancelEvent(e);
};

this.mousewheel = function(fn) {
if (!self.isie) self.bind(self.docscroll,'DOMMouseScroll',self.onmousewheel,false);
self.bind(self.docscroll,'mousewheel',self.onmousewheel,false);
if (!self.ispage) {
if (!self.isie) self.bind(self.rail,'DOMMouseScroll',self.onmousewheel,false);
self.bind(self.rail,'mousewheel',self.onmousewheel,false);
}
};

this.doScroll = function(y) {
self.newscrolly = y;
if (self.timer) return;
Expand Down Expand Up @@ -402,8 +393,8 @@

$.fn.niceScroll = function(opt) {
var ret = [];
if (opt===undefined) opt = {};
var docundef = (opt.doc===undefined);
if (typeof opt=="undefined") opt = {};
var docundef = !("doc" in opt);
this.each(function() {
opt.doc = (docundef) ? $(this) : opt.doc;
ret.push(new NiceScrollClass(opt));
Expand Down

0 comments on commit 245d9b7

Please sign in to comment.