Skip to content

Commit

Permalink
Fix visibility inside scroll context
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Feb 23, 2017
1 parent e910937 commit b962d89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## RELEASE NOTES

### Version 2.2.10 - February 21, 2017

**Bugs**
**Visibility** - Fixed bug where using visibility with `context` setting on a scrollable context (with overflow) would cause callbacks to fire incorrectly

### Version 2.2.9 - February 21, 2017

**Build Tools**
Expand Down
13 changes: 13 additions & 0 deletions src/definitions/behaviors/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ $.fn.visibility = function(parameters) {
return !(module.cache.element.width === 0 && module.cache.element.offset.top === 0);
}
return false;
},
verticallyScrollableContext: function() {
return $context.get(0) !== window && $context.css('overflow-y') == 'auto';
},
horizontallyScrollableContext: function() {
return $context.get(0) !== window && $context.css('overflow-x') == 'auto';
}
},

Expand Down Expand Up @@ -879,6 +885,13 @@ $.fn.visibility = function(parameters) {
element.offset = $module.offset();
element.width = $module.outerWidth();
element.height = $module.outerHeight();
// compensate for scroll in context
if(module.is.verticallyScrollableContext()) {
element.offset.top += $context.scrollTop();
}
if(module.is.horizontallyScrollableContext()) {
element.offset.left += $context.scrollLeft();
}
// store
module.cache.element = element;
return element;
Expand Down

0 comments on commit b962d89

Please sign in to comment.