10 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@egjs/component")):"function"==typeof define&&define.amd?define(["@egjs/component"],t):"object"==typeof exports?exports.Visible=t(require("@egjs/component")):(e.eg=e.eg||{},e.eg.Visible=t(e.eg.Component))}(this,function(e){return function(e){function __webpack_require__(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,__webpack_require__),n.l=!0,n.exports}var t={};return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,r){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=0)}([function(e,t,r){"use strict";var n=r(1),i=function(e){return e&&e.__esModule?e:{"default":e}}(n);e.exports=i["default"]},function(e,t,r){"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(2),s=function(e){return e&&e.__esModule?e:{"default":e}}(o),c=r(3);"function"!=typeof Object.create&&(Object.create=function(e,t){function F(){}if("object"!==(void 0===e?"undefined":i(e))&&"function"!=typeof e)throw new TypeError("Object prototype may only be an Object: "+e);if(null===e)throw new Error("This browser's implementation of Object.create is a shim and doesn't support 'null' as the first argument.");return F.prototype=e,new F});var a=!!window.IntersectionObserver,u=function(){var e=document.createElement("div");if(!e.getElementsByClassName)return!1;var t=e.getElementsByClassName("dummy");return e.innerHTML="<span class='dummy'></span>",1===t.length}(),l=function(e){function Visible(t,r){_classCallCheck(this,Visible);var i=_possibleConstructorReturn(this,e.call(this));return i.options={targetClass:"check_visible",expandSize:0},n(i.options,r),i._wrapper=(0,c.$)(t)||document,i._wrapper.nodeType&&1===i._wrapper.nodeType?i._getAreaRect=i._getWrapperRect:i._getAreaRect=c.getWindowRect,i._targets=[],i._timer=null,i.refresh(),i}return _inherits(Visible,e),Visible.prototype.refresh=function(){return u?(this._targets=this._wrapper.getElementsByClassName(this.options.targetClass),this.refresh=function(){return this._refreshObserver(),this}):this.refresh=function(){var e=this._wrapper.querySelectorAll("."+this.options.targetClass);this._targets=[];for(var t=0;t<e.length;t++)this._targets.push(e[t]);return this._refreshObserver(),this},this.refresh()},Visible.prototype.check=function(){var e=this,t=arguments.length<=0?undefined:arguments[0],r=arguments.length<=1?undefined:arguments[1];return"number"!=typeof t&&(r=t,t=-1),void 0===t&&(t=-1),void 0===r&&(r=!1),clearTimeout(this._timer),t<0?(this._check(r),this._checkAfter()):this._timer=setTimeout(function(){e._check(r),e._checkAfter(),e._timer=null},t),this},Visible.prototype.getVisibleElements=function(){for(var e=this._targets,t=[],r=0;r<e.length;r++){var n=e[r];n&&!0===n.__VISIBLE__&&t.push(n)}return t},Visible.prototype._getWrapperRect=function(){return this._wrapper.getBoundingClientRect()},Visible.prototype._reviseElements=function(){var e=this;return this._reviseElements=u?function(){return!0}:function(t,r){return!!(0,c.hasClass)(t,e.options.targetClass)||(t.__VISIBLE__=null,e._targets.splice(r,1),!1)},this._reviseElements.apply(this,arguments)},Visible.prototype._check=function(e){var t=parseInt(this.options.expandSize,10),r=void 0,n=void 0,i=void 0,o=void 0,s=this._getAreaRect(),c={top:s.top-t,left:s.left-t,bottom:s.bottom+t,right:s.right+t};for(r=this._targets.length-1;n=this._targets[r];r--)i=n.getBoundingClientRect(),0===i.width&&0===i.height||this._reviseElements(n,r)&&(o=e?!(i.top<c.top||i.bottom>c.bottom||i.right>c.right||i.left<c.left):!(i.bottom<c.top||c.bottom<i.top||i.right<c.left||c.right<i.left),n.__AFTER__=o)},Visible.prototype.checkObserve=function(){var e=this,t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:-1;return this._timer&&(clearTimeout(this._timer),this._timer=0),t<0?this._checkAfter():this._timer=setTimeout(function(){e._checkAfter(),e._timer=null},t),this},Visible.prototype._checkAfter=function(){for(var e=this._targets,t=e.length,r=[],n=[],i=0;i<t;++i){var o=e[i],s=o.__VISIBLE__,c=o.__AFTER__;s!==c&&(c?r.push(o):n.push(o),o.__VISIBLE__=c)}0===r.length&&0===n.length||this.trigger("change",{visible:r,invisible:n,isTrusted:!0})},Visible.prototype.observe=function(){var e=this,t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(!a)return this._addObserveEvent(t),this;var r="undefined"==typeof t.delay?-1:t.delay,n=!!t.containment;this._observeCallback=function(t){t.forEach(function(e){e.target.__AFTER__=n?e.intersectionRatio>=1:e.isIntersecting}),e._checkAfter(r)},this._observer&&this.unobserve(),this._observer=new IntersectionObserver(this._observeCallback,{root:1===this._wrapper.nodeType?this._wrapper:null,rootMargin:this.options.expandSize+"px",threshold:n?[0,1]:[0]});for(var i=this._observer,o=this._targets,s=o.length,c=0;c<s;++c)i.observe(o[c]);return this},Visible.prototype.unobserve=function(){return this._observeCallback?(a?this._observer&&this._observer.disconnect():((0,c.removeEvent)(this._wrapper,"scroll",this._observeCallback),(0,c.removeEvent)(this._wrapper,"resize",this._observeCallback)),this._observer=null,this._observeCallback=null,this):this},Visible.prototype._refreshObserver=function(){if(this._observer){this._observer.disconnect();for(var e=this._targets,t=e.length,r=0;r<t;++r)this._observer.observe(e[r])}},Visible.prototype._addObserveEvent=function(){var e=this,t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(!this._observeCallback){var r="undefined"==typeof t.delay?-1:t.delay,n=!!t.containment;this._observeCallback=function(t){e._check(n),e.checkObserve(r)},(0,c.addEvent)(this._wrapper,"scroll",this._observeCallback),(0,c.addEvent)(this._wrapper,"resize",this._observeCallback),this._observeCallback()}},Visible.prototype.destroy=function(){this.off(),this.unobserve(),this._targets=[],this._wrapper=null,this._timer=null},Visible}(s["default"]);l.VERSION="2.2.0",t["default"]=l,e.exports=t["default"]},function(t,r){t.exports=e},function(e,t,r){"use strict";function toArray(e){var t=[];if(e)for(var r=0,n=e.length;r<n;r++)t.push(e[r]);return t}function $(e){var t=arguments.length>1&&arguments[1]!==undefined&&arguments[1],r=void 0;if(e===undefined)return undefined;if("string"==typeof e){if(e.match(/^<([a-z]+)\s*([^>]*)>/)){var n=document.createElement("div");n.innerHTML=e,r=toArray(n.childNodes)}else r=toArray(document.querySelectorAll(e));t||(r=r.length>=1?r[0]:undefined)}else e===window?r=e:!e.nodeName||1!==e.nodeType&&9!==e.nodeType?"jQuery"in window&&e instanceof jQuery||e.constructor.prototype.jquery?r=t?e.toArray():e.get(0):Array.isArray(e)&&(r=e.map(function(e){return $(e)}),t||(r=r.length>=1?r[0]:undefined)):r=e;return r}function getWindowRect(){return{top:0,left:0,bottom:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,right:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}function hasClass(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function addEvent(e,t,r,s){if(i){var c=s||!1;"object"===(void 0===s?"undefined":n(s))&&(c=!!o&&s),e.addEventListener(t,r,c)}else e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r}function removeEvent(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null}t.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.toArray=toArray,t.$=$,t.getWindowRect=getWindowRect,t.hasClass=hasClass,t.addEvent=addEvent,t.removeEvent=removeEvent;var i=!!("addEventListener"in document),o=function(){var e=!1;try{i&&Object.defineProperty&&document.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){e=!0}}))}catch(t){}return e}()}])}); |