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 @@ + + + + + + impression + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + diff --git a/test/manual-test.css b/test/manual-test.css new file mode 100644 index 0000000..0f05204 --- /dev/null +++ b/test/manual-test.css @@ -0,0 +1,42 @@ +/** + * @since 2019-05-29 20:58 + * @author vivaxy + */ + +html { + width: 100%; +} + +body { + margin: 0; + width: 100%; +} + +.element { + width: 100px; + height: 100px; +} + +.element:nth-child(6n) { + background-color: #f99; +} + +.element:nth-child(6n+1) { + background-color: #9f9; +} + +.element:nth-child(6n+2) { + background-color: #99f; +} + +.element:nth-child(6n+3) { + background-color: #ff9; +} + +.element:nth-child(6n+4) { + background-color: #f9f; +} + +.element:nth-child(6n+5) { + background-color: #9ff; +} diff --git a/test/manual-test.html b/test/manual-test.html index 6a53491..2b27a62 100644 --- a/test/manual-test.html +++ b/test/manual-test.html @@ -1,39 +1,10 @@ - + impression - +
@@ -41,15 +12,21 @@
+
+
+
+
+
+
+
+