Browse Source

Fix visibility inside scroll context

pull/5096/head
Jack Lukic 8 years ago
parent
commit
b962d899f1
2 changed files with 18 additions and 0 deletions
  1. 5
      RELEASE-NOTES.md
  2. 13
      src/definitions/behaviors/visibility.js

5
RELEASE-NOTES.md

@ -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**

13
src/definitions/behaviors/visibility.js

@ -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';
}
},
@ -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;

Loading…
Cancel
Save