From 7dd55d24e568386af13b8610aaa01b3484f5d6b0 Mon Sep 17 00:00:00 2001 From: ninnypants Date: Mon, 7 May 2012 13:36:54 -0600 Subject: [PATCH] Removed DOMMouseScroll event to fix double scroll in Firefox --- script/jquery.scrollpath.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/script/jquery.scrollpath.js b/script/jquery.scrollpath.js index fafed68..359862d 100644 --- a/script/jquery.scrollpath.js +++ b/script/jquery.scrollpath.js @@ -52,7 +52,7 @@ /* Initializes the plugin */ init: function( options ) { if ( this.length > 1 || isInitialized ) $.error( "jQuery.scrollPath can only be initialized on *one* element *once*" ); - + $.extend( settings, options ); isInitialized = true; element = this; @@ -64,7 +64,6 @@ $( document ).on({ "mousewheel": scrollHandler, - "DOMMouseScroll": scrollHandler, // Firefox "keydown": keyHandler, "mousedown": function( e ) { if( e.button === 1 ) { @@ -100,7 +99,7 @@ return this; } }; - + /* The Path object serves as a context to "draw" the scroll path on before initializing the plugin */ function Path( scrollS, rotateS ) { @@ -131,7 +130,7 @@ steps = Math.round( rotDistance / rotationSpeed ) * STEP_SIZE, rotStep = ( radians - rotation ) / steps, i = 1; - + if ( !HAS_TRANSFORM_SUPPORT ) { if ( settings.name || settings.callback ) { // In case there was a name or callback set to this path, we add an extra step with those @@ -143,7 +142,7 @@ } return this; } - + for( ; i <= steps; i++ ) { path.push({ x: xPos, y: yPos, @@ -233,7 +232,7 @@ if ( xPos !== startX || yPos !== startY ) { this.lineTo( startX, startY ); } - + for ( ; i <= steps; i++ ) { path.push({ x: centerX + radius * Math.cos( startAngle + radStep*i ), y: centerY + radius * Math.sin( startAngle + radStep*i ), @@ -333,7 +332,7 @@ e.preventDefault(); return false; }); - + scrollHandle = $( "
" ). addClass( "sp-scroll-handle" ). on({ @@ -354,7 +353,7 @@ }); $( "body" ).prepend( scrollBar.append( scrollHandle ) ); - + } /* Initializes the path canvas */ @@ -369,18 +368,18 @@ top: pathObject.getPathOffsetY(), "pointer-events": "none" }; - + applyPrefix( style, "user-select", "none" ); applyPrefix( style, "user-drag", "none" ); - + canvas = $( "" ). addClass( "sp-canvas" ). css( style ). prependTo( element ); - + canvas[ 0 ].width = pathObject.getPathWidth(); canvas[ 0 ].height = pathObject.getPathHeight(); - + drawCanvasPath( canvas[ 0 ].getContext( "2d" ), pathObject.getCanvasPath() ); } @@ -525,7 +524,7 @@ var centeredX = node.x - $( window ).width() / 2, centeredY = node.y - $( window ).height() / 2, style = {}; - + // Only use transforms when page is rotated if ( normalizeAngle(node.rotate) === 0 ) { style.left = -centeredX; @@ -595,7 +594,7 @@ nEnd = normalizeAngle( end ), diff = Math.abs( nStart - nEnd ), invDiff = Math.PI * 2 - diff; - + if ( ( ccw && nStart < nEnd ) || ( !ccw && nStart > nEnd ) || ( nStart === nEnd && start !== end ) // Special case * @@ -626,7 +625,7 @@ if( mod > snapValue / 2) return value + snapValue - mod; return value - mod; } - + /* Normalizes a given angle (sets it between 0 and 2 * Math.PI) */ function normalizeAngle( angle ) { while( angle < 0 ) {