Skip to content

Commit

Permalink
#3193, renames scroll to scrollContext for clarification internally, …
Browse files Browse the repository at this point in the history
…adds fits check
  • Loading branch information
jlukic committed Nov 1, 2015
1 parent 2e9e7d3 commit 9856d4b
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/definitions/modules/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ $.fn.sticky = function(parameters) {
},
positions: function() {
var
window = {
height: $window.height()
scrollContext = {
height : $scroll.height()
},
element = {
margin: {
Expand All @@ -241,24 +241,23 @@ $.fn.sticky = function(parameters) {
},
container = {
height: $container.outerHeight()
},
scroll
}
;
if(!module.is.standardScroll()) {
if( !module.is.standardScroll() ) {
module.debug('Non-standard scroll. Removing scroll offset from element offset');
scroll = {
top : $scroll.scrollTop(),
left : $scroll.scrollLeft()
}
element.offset.top += scroll.top;
context.offset.top += scroll.top;
element.offset.left += scroll.left;
context.offset.left += scroll.left;

scrollContext.top = $scroll.scrollTop();
scrollContext.left = $scroll.scrollLeft();

element.offset.top += scrollContext.top;
context.offset.top += scrollContext.top;
element.offset.left += scrollContext.left;
context.offset.left += scrollContext.left;
}
module.cache = {
fits : ( element.height < window.height ),
window : {
height: window.height
fits : ( element.height < scrollContext.height ),
scrollContext : {
height : scrollContext.height
},
element: {
margin : element.margin,
Expand Down Expand Up @@ -318,9 +317,9 @@ $.fn.sticky = function(parameters) {
scroll = scroll || $scroll.scrollTop();
var
element = module.cache.element,
window = module.cache.window,
scrollContext = module.cache.scrollContext,
delta = module.get.scrollChange(scroll),
maxScroll = (element.height - window.height + settings.offset),
maxScroll = (element.height - scrollContext.height + settings.offset),
elementScroll = module.get.currentElementScroll(),
possibleScroll = (elementScroll + delta)
;
Expand Down Expand Up @@ -438,14 +437,14 @@ $.fn.sticky = function(parameters) {
cache = module.cache,
fits = cache.fits,
element = cache.element,
window = cache.window,
scrollContext = cache.scrollContext,
context = cache.context,
offset = (module.is.bottom() && settings.pushing)
? settings.bottomOffset
: settings.offset,
scroll = {
top : cachedPosition + offset,
bottom : cachedPosition + offset + window.height
bottom : cachedPosition + offset + scrollContext.height
},
direction = module.get.direction(scroll.top),
elementScroll = (fits)
Expand Down

0 comments on commit 9856d4b

Please sign in to comment.