Skip to content

Commit

Permalink
build dist
Browse files Browse the repository at this point in the history
  • Loading branch information
sjwilliams committed Sep 21, 2018
1 parent aae4aea commit 7a30940
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion dist/jquery.scrollstory.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@
*
* 0 means the first item isn't yet active,
* and 1 means the last item is active, or
* has already be scrolled beyond.
* has already been scrolled beyond active.
*
* @return {[type]} [description]
*/
Expand All @@ -669,6 +669,15 @@
},


/**
* Progress of the entire scroll distance, from the start
* of the first item a '0', until the very end of the last
* item, which is '1';
*/
getScrollComplete: function() {
return this._totalScrollComplete || 0;
},

/**
* Return an array of all filtered items.
* @return {Array}
Expand Down Expand Up @@ -1085,6 +1094,9 @@
var rect;
var previouslyInViewport;

// track total scroll across all items
var totalScrollComplete = 0;

for (i = 0; i < length; i++) {
item = items[i];
rect = item.el[0].getBoundingClientRect();
Expand All @@ -1100,6 +1112,9 @@
item.percentScrollComplete = Math.abs(item.distanceToOffset) / rect.height;
}

// track percent scroll
totalScrollComplete = totalScrollComplete + item.percentScrollComplete;

// track viewport status
previouslyInViewport = item.inViewport;
item.inViewport = rect.bottom > 0 && rect.right > 0 && rect.left < wWidth && rect.top < wHeight;
Expand Down Expand Up @@ -1128,6 +1143,8 @@
}

this._percentScrollToLastItem = percentScrollToLastItem;

this._totalScrollComplete = totalScrollComplete / length;
},


Expand Down
Loading

0 comments on commit 7a30940

Please sign in to comment.