Skip to content

Commit

Permalink
fixed offset
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpolacek committed Dec 23, 2011
1 parent 50d140f commit c4aa91f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/jquery.scrollorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
onBlockChange = function() {};

var scrollorama = this;
scrollorama.settings = options;

var defaults = {offset:0};

scrollorama.settings = $.extend({}, defaults, options);
scrollorama.blockIndex = 0;

if (options.blocks === undefined) alert('ERROR: Must assign blocks class selector to scrollorama plugin');

// PRIVATE FUNCTIONS
function init() {
if (typeof scrollorama.settings.blocks === 'string') scrollorama.settings.blocks = $(scrollorama.settings.blocks);
Expand Down Expand Up @@ -138,7 +143,7 @@
var currBlockIndex = 0;
for (var i=0; i<blocks.length; i++) {
// check if block is in view
if (blocks[i].top < scrollTop) currBlockIndex = i;
if (blocks[i].top <= scrollTop - scrollorama.settings.offset) currBlockIndex = i;
}
return currBlockIndex;
}
Expand Down

0 comments on commit c4aa91f

Please sign in to comment.