Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Also sort on offset().left
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Koc committed Jun 13, 2017
1 parent 768ed2b commit 047f05d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions dist/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* scroll.js
* Adds a class when scrolling past selected elements
*
* @version 1.0.4
* @version 1.0.5
* @author Emre Koc <[email protected]>
*/
'use strict';
Expand Down Expand Up @@ -76,13 +76,16 @@ function resizeCalculate() {
documentHeight = document.body.scrollHeight - windowHeight * 0.3;

var i = void 0,
o = void 0,
item = void 0;
for (i = 0; i < items.length; i++) {
item = items[i];
item.top = item.element.offset().top;
o = item.element.offset();
item.top = o.top;
item.left = o.left;
}

var keys = ['sort', 'top'];
var keys = ['sort', 'top', 'left'];
items.sort(function (a, b) {
var i = 0;
var aVal = a[keys[i]];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scroll.js",
"version": "1.0.4",
"version": "1.0.5",
"description": "Adds a class when scrolling past selected elements",
"main": "dist/scroll.js",
"license": "MIT",
Expand Down
9 changes: 5 additions & 4 deletions src/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ function resizeCalculate() {
windowHeightGapped = windowHeight * (1 - options.gap);
documentHeight = document.body.scrollHeight - windowHeight * 0.3;

let i, item;
let i, o, item;
for (i=0; i<items.length; i++) {
item = items[i];
item.top = item.element.offset().top;

o = item.element.offset();
item.top = o.top;
item.left = o.left;
}

let keys = ['sort', 'top'];
let keys = ['sort', 'top', 'left'];
items.sort(function(a, b) {
let i = 0;
let aVal = a[keys[i]];
Expand Down

0 comments on commit 047f05d

Please sign in to comment.