Skip to content
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
29 changes: 13 additions & 16 deletions jquery.scrolldepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
percentage: true,
userTiming: true,
pixelDepth: true,
nonInteraction: true
nonInteraction: true,
bottomElement: ''
};

var $window = $(window),
cache = [],
lastPixelDepth = 0,
universalGA,
classicGA,
standardEventHandler;
cache = [],
lastPixelDepth = 0,
universalGA,
classicGA,
standardEventHandler;

/*
* Plugin
Expand Down Expand Up @@ -228,15 +229,11 @@
* account for dynamic DOM changes.
*/

var docHeight = $(document).height(),
winHeight = window.innerHeight ? window.innerHeight : $window.height(),
scrollDistance = $window.scrollTop() + winHeight,

// Recalculate percentage marks
marks = calculateMarks(docHeight),

// Timing
timing = +new Date - startTime;
var docHeight = options.bottomElement ? $(options.bottomElement).offset().top : $(document).height(),
winHeight = window.innerHeight ? window.innerHeight : $window.height(),
scrollDistance = $window.scrollTop() + winHeight,
marks = calculateMarks(docHeight),
timing = +new Date - startTime;

// If all marks already hit, unbind scroll event
if (cache.length >= 4 + options.elements.length) {
Expand All @@ -257,4 +254,4 @@

};

})( jQuery, window, document );
})( jQuery, window, document );