tinyscrollbar minor update
This commit is contained in:
1 parent
3182f5c9a8
commit
db2b371744
5 files changed
+55
-18
No files matched your search
@@ -11,19 +11,20 @@
|
||||
* Depends on library: jQuery
|
||||
*
|
||||
*/
|
||||
( function( $ )
|
||||
;( function( $ )
|
||||
{
|
||||
$.tiny = $.tiny || { };
|
||||
|
||||
$.tiny.scrollbar = {
|
||||
options: {
|
||||
axis : 'y' // vertical or horizontal scrollbar? ( x || y ).
|
||||
, wheel : 40 // how many pixels must the mouswheel scroll at a time.
|
||||
, scroll : true // enable or disable the mousewheel.
|
||||
, lockscroll : true // return scrollwheel to browser if there is no more content.
|
||||
, size : 'auto' // set the size of the scrollbar to auto or a fixed number.
|
||||
, sizethumb : 'auto' // set the size of the thumb to auto or a fixed number.
|
||||
, onMove : function(){}
|
||||
axis : 'y' // vertical or horizontal scrollbar? ( x || y ).
|
||||
, wheel : 40 // how many pixels must the mouswheel scroll at a time.
|
||||
, scroll : true // enable or disable the mousewheel.
|
||||
, lockscroll : true // return scrollwheel to browser if there is no more content.
|
||||
, size : 'auto' // set the size of the scrollbar to auto or a fixed number.
|
||||
, sizethumb : 'auto' // set the size of the thumb to auto or a fixed number.
|
||||
, invertscroll : false // Enable mobile invert style scrolling
|
||||
, onMove : function(){}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,13 +60,15 @@
|
||||
, iScroll = 0
|
||||
, iPosition = { start: 0, now: 0 }
|
||||
, iMouse = {}
|
||||
, touchEvents = ( 'ontouchstart' in document.documentElement ) ? true : false
|
||||
, touchEvents = 'ontouchstart' in document.documentElement
|
||||
, UA = $.browser
|
||||
;
|
||||
|
||||
function initialize()
|
||||
{
|
||||
oSelf.update();
|
||||
setEvents();
|
||||
|
||||
return oSelf;
|
||||
}
|
||||
|
||||
@@ -124,6 +127,9 @@
|
||||
{
|
||||
oWrapper[0].addEventListener( 'DOMMouseScroll', wheel, false );
|
||||
oWrapper[0].addEventListener( 'mousewheel', wheel, false );
|
||||
oWrapper[0].addEventListener( 'MozMousePixelScroll', function( event ){
|
||||
event.preventDefault();
|
||||
}, false);
|
||||
}
|
||||
else if( options.scroll )
|
||||
{
|
||||
@@ -133,6 +139,16 @@
|
||||
|
||||
function start( event )
|
||||
{
|
||||
$( "body" ).addClass( "noSelect" );
|
||||
// Disable select text under IE10
|
||||
if ( UA.msie < 10 ){
|
||||
$( "body" ).attr({
|
||||
"onselectstart": "return false",
|
||||
"ondragstart": "return false"
|
||||
});
|
||||
}
|
||||
oScrollbar.obj.addClass( "dragging" );
|
||||
|
||||
var oThumbDir = parseInt( oThumb.obj.css( sDirection ), 10 );
|
||||
iMouse.start = sAxis ? event.pageX : event.pageY;
|
||||
iPosition.start = oThumbDir == 'auto' ? 0 : oThumbDir;
|
||||
@@ -181,13 +197,13 @@
|
||||
{
|
||||
if( oContent.ratio < 1 )
|
||||
{
|
||||
if( ! touchEvents )
|
||||
if( options.invertscroll && touchEvents )
|
||||
{
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( ( sAxis ? event.pageX : event.pageY ) - iMouse.start))));
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( iMouse.start - ( sAxis ? event.pageX : event.pageY ) ))));
|
||||
}
|
||||
else
|
||||
{
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( iMouse.start - ( sAxis ? event.pageX : event.pageY ) ))));
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( ( sAxis ? event.pageX : event.pageY ) - iMouse.start))));
|
||||
}
|
||||
|
||||
iScroll = iPosition.now * oScrollbar.ratio;
|
||||
@@ -198,6 +214,12 @@
|
||||
|
||||
function end()
|
||||
{
|
||||
$( "body" ).removeClass( "noSelect" );
|
||||
// Enable select text under IE10
|
||||
if ( UA.msie < 10 ){
|
||||
$( "body" ).removeAttr( "onselectstart", "ondragstart" );
|
||||
}
|
||||
oScrollbar.obj.removeClass( "dragging" );
|
||||
$( document ).unbind( 'mousemove', drag );
|
||||
$( document ).unbind( 'mouseup', end );
|
||||
oThumb.obj.unbind( 'mouseup', end );
|
||||
|
||||
Reference in new issue
Block a user