Skip to content

Commit

Permalink
Merge pull request #4 from windsurfer/master
Browse files Browse the repository at this point in the history
A few tweaks and fixes
  • Loading branch information
JoelBesada committed Mar 16, 2012
2 parents cfa091f + 2b16ce5 commit ecd7fe3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 35 deletions.
15 changes: 2 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
<script type="text/javascript" src="script/prefixfree.min.js"></script>
<meta name="description" content="The plugin that lets you define custom scroll paths" />
<title>jQuery Scroll Path</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25206568-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<ul class="navigation">
Expand Down Expand Up @@ -68,7 +57,7 @@ <h1>jQuery Scroll Path</h1>
</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript" src="script/jquery.easing.js"></script>
<script type="text/javascript" src="script/jquery.scrollpath.min.js"></script>
<script type="text/javascript" src="script/jquery.scrollpath.js"></script>
<script type="text/javascript" src="script/demo.js"></script>
</body>
</html>
</html>
15 changes: 8 additions & 7 deletions script/jquery.scrollpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
var PREFIX = "-" + getVendorPrefix().toLowerCase() + "-",
HAS_TRANSFORM_SUPPORT = supportsTransforms(),
HAS_CANVAS_SUPPORT = supportsCanvas(),
FPS = 30,
STEP_SIZE = 10, // Number of actual path steps per scroll steps.
FPS = 60,
STEP_SIZE = 50, // Number of actual path steps per scroll steps.
// The extra steps are needed to make animations look smooth.
isInitiated = false,
isDragging = false,
Expand Down Expand Up @@ -320,8 +320,7 @@
scrollBar = $( "<div>" ).
addClass( "sp-scroll-bar" ).
on( "click", function( e ) {
var clickStep = Math.round( e.offsetY / scrollBar.height() * ( pathList.length - 1) );

var clickStep = Math.round( (e.offsetY || e.clientY) / scrollBar.height() * ( pathList.length - 1) );
// Close in on the clicked part instead of jumping directly to it.
// This mimics the default browser scroll bar behavior.
if ( Math.abs(clickStep - step) > 5 ) {
Expand Down Expand Up @@ -476,9 +475,11 @@
/* Scrolls to a specified step */
function scrollToStep( stepParam, fromAnimation ) {
if ( isAnimating && !fromAnimation ) return;
var cb = pathList[ stepParam ].callback;

element.css( makeCSS( pathList[ stepParam ] ) );
var cb;
if (pathList[ stepParam ] ){
cb = pathList[ stepParam ].callback;
element.css( makeCSS( pathList[ stepParam ] ) );
}
if( scrollHandle ) scrollHandle.css( "top", stepParam / (pathList.length - 1 ) * ( scrollBar.height() - scrollHandle.height() ) + "px" );
if ( cb && stepParam !== step && !isAnimating ) cb();
step = stepParam;
Expand Down
14 changes: 0 additions & 14 deletions script/jquery.scrollpath.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ a:active {
}

.highlight {
animation: highlight 1s alternate 2;
animation: highlight 0.2s alternate 6 ;
}

@keyframes point-down {
Expand Down

0 comments on commit ecd7fe3

Please sign in to comment.