diff --git a/bundle/impression.rollup.js b/bundle/impression.rollup.js index e8c06df..15c62e7 100644 --- a/bundle/impression.rollup.js +++ b/bundle/impression.rollup.js @@ -1,4 +1,4 @@ -/* @vivaxy/impression@v2.0.0 by vivaxy */ +/* @vivaxy/impression@v2.1.0 by vivaxy */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -595,7 +595,7 @@ var scrollEvents = (function (container) { return callback(SCROLL); }; presets(container); - container.addEventListener(SCROLL$1, _callback); + container.addEventListener(SCROLL$1, _callback, true); return true; } @@ -603,7 +603,7 @@ var scrollEvents = (function (container) { var off = function off() { if (attached) { - container.removeEventListener(SCROLL$1, _callback); + container.removeEventListener(SCROLL$1, _callback, true); attached = false; return true; } else { diff --git a/bundle/impression.webpack.js b/bundle/impression.webpack.js index afe68fd..1ada746 100644 --- a/bundle/impression.webpack.js +++ b/bundle/impression.webpack.js @@ -1,4 +1,4 @@ -/*! @vivaxy/impression@v2.0.0 by vivaxy */ +/*! @vivaxy/impression@v2.1.0 by vivaxy */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -1243,7 +1243,7 @@ exports.default = function (container) { return callback(observers.SCROLL); }; (0, _presets2.default)(container); - container.addEventListener(SCROLL, _callback); + container.addEventListener(SCROLL, _callback, true); return true; } @@ -1251,7 +1251,7 @@ exports.default = function (container) { var off = function off() { if (attached) { - container.removeEventListener(SCROLL, _callback); + container.removeEventListener(SCROLL, _callback, true); attached = false; return true; } else { diff --git a/dist/observers/scroll.js b/dist/observers/scroll.js index af5b3f4..eeed143 100644 --- a/dist/observers/scroll.js +++ b/dist/observers/scroll.js @@ -36,7 +36,7 @@ exports.default = function (container) { return callback(observers.SCROLL); }; (0, _presets2.default)(container); - container.addEventListener(SCROLL, _callback); + container.addEventListener(SCROLL, _callback, true); return true; } @@ -44,7 +44,7 @@ exports.default = function (container) { var off = function off() { if (attached) { - container.removeEventListener(SCROLL, _callback); + container.removeEventListener(SCROLL, _callback, true); attached = false; return true; } else { diff --git a/source/observers/scroll.js b/source/observers/scroll.js index 9c88ad8..6611392 100644 --- a/source/observers/scroll.js +++ b/source/observers/scroll.js @@ -21,7 +21,8 @@ export default (container) => { return callback(observers.SCROLL); }; presets(container); - container.addEventListener(SCROLL, _callback); + // `scroll` event not propagation when it happens in an element. Bind event at capture resolve this problem. + container.addEventListener(SCROLL, _callback, true); return true; } @@ -29,7 +30,7 @@ export default (container) => { const off = () => { if (attached) { - container.removeEventListener(SCROLL, _callback); + container.removeEventListener(SCROLL, _callback, true); attached = false; return true; } else { diff --git a/test/manual-test-scroll.html b/test/manual-test-scroll.html new file mode 100644 index 0000000..8e3d5c4 --- /dev/null +++ b/test/manual-test-scroll.html @@ -0,0 +1,75 @@ + + +
+ + +