Browse Source

#3193, renames scroll to scrollContext for clarification internally, adds fits check

pull/3277/head
Jack 9 years ago
parent
commit
9856d4bb41
1 changed files with 19 additions and 20 deletions
  1. 39
      src/definitions/modules/sticky.js

39
src/definitions/modules/sticky.js

@ -223,8 +223,8 @@ $.fn.sticky = function(parameters) {
},
positions: function() {
var
window = {
height: $window.height()
scrollContext = {
height : $scroll.height()
},
element = {
margin: {
@ -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,
@ -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)
;
@ -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)

Loading…
Cancel
Save