diff --git a/src/components/tooltip/Tooltip.js b/src/components/tooltip/Tooltip.js index a861183af..36d609a64 100755 --- a/src/components/tooltip/Tooltip.js +++ b/src/components/tooltip/Tooltip.js @@ -1,5 +1,6 @@ import UniqueComponentId from '../utils/UniqueComponentId'; import DomHandler from '../utils/DomHandler'; +import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler'; function bindEvents(el) { const modifiers = el.$_ptooltipModifiers; @@ -27,6 +28,22 @@ function unbindEvents(el) { } } +function bindScrollListener(el) { + if (!el.$_ptooltipScrollHandler) { + el.$_ptooltipScrollHandler = new ConnectedOverlayScrollHandler(el, function() { + hide(el); + }); + } + + el.$_ptooltipScrollHandler.bindScrollListener(); +} + +function unbindScrollListener(el) { + if (el.$_ptooltipScrollHandler) { + el.$_ptooltipScrollHandler.unbindScrollListener(); + } +} + function onMouseEnter(event) { show(event.currentTarget); } @@ -61,10 +78,13 @@ function show(el) { hide(el); this.removeEventListener('resize', onWindowResize); }); + + bindScrollListener(el); } function hide(el) { remove(el); + unbindScrollListener(el); } function getTooltipElement(el) { @@ -225,6 +245,11 @@ const Tooltip = { unmounted(el) { remove(el); unbindEvents(el); + + if (el.$_ptooltipScrollHandler) { + el.$_ptooltipScrollHandler.destroy(); + el.$_ptooltipScrollHandler = null; + } }, updated(el, options) { el.$_ptooltipModifiers = options.modifiers; @@ -232,4 +257,4 @@ const Tooltip = { } }; -export default Tooltip; \ No newline at end of file +export default Tooltip;