Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hash based navigation #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions script/jquery.scrollpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,7 +100,7 @@
return this;
}
};

/* The Path object serves as a context to "draw" the scroll path
on before initializing the plugin */
function Path( scrollS, rotateS ) {
Expand Down Expand Up @@ -131,7 +131,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
Expand All @@ -143,7 +143,7 @@
}
return this;
}

for( ; i <= steps; i++ ) {
path.push({ x: xPos,
y: yPos,
Expand Down Expand Up @@ -233,7 +233,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 ),
Expand Down Expand Up @@ -333,7 +333,7 @@
e.preventDefault();
return false;
});

scrollHandle = $( "<div>" ).
addClass( "sp-scroll-handle" ).
on({
Expand All @@ -354,7 +354,7 @@
});

$( "body" ).prepend( scrollBar.append( scrollHandle ) );

}

/* Initializes the path canvas */
Expand All @@ -369,18 +369,18 @@
top: pathObject.getPathOffsetY(),
"pointer-events": "none"
};

applyPrefix( style, "user-select", "none" );
applyPrefix( style, "user-drag", "none" );

canvas = $( "<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() );
}

Expand Down Expand Up @@ -525,7 +525,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;
Expand Down Expand Up @@ -595,7 +595,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 *
Expand Down Expand Up @@ -626,7 +626,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 ) {
Expand Down