index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ i: moduleId,
  13. /******/ l: false,
  14. /******/ exports: {}
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.l = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // identity function for calling harmony imports with the correct context
  28. /******/ __webpack_require__.i = function(value) { return value; };
  29. /******/ // define getter function for harmony exports
  30. /******/ __webpack_require__.d = function(exports, name, getter) {
  31. /******/ if(!__webpack_require__.o(exports, name)) {
  32. /******/ Object.defineProperty(exports, name, {
  33. /******/ configurable: false,
  34. /******/ enumerable: true,
  35. /******/ get: getter
  36. /******/ });
  37. /******/ }
  38. /******/ };
  39. /******/ // getDefaultExport function for compatibility with non-harmony modules
  40. /******/ __webpack_require__.n = function(module) {
  41. /******/ var getter = module && module.__esModule ?
  42. /******/ function getDefault() { return module['default']; } :
  43. /******/ function getModuleExports() { return module; };
  44. /******/ __webpack_require__.d(getter, 'a', getter);
  45. /******/ return getter;
  46. /******/ };
  47. /******/ // Object.prototype.hasOwnProperty.call
  48. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  49. /******/ // __webpack_public_path__
  50. /******/ __webpack_require__.p = "";
  51. /******/ // Load entry module and return exports
  52. /******/ return __webpack_require__(__webpack_require__.s = 222);
  53. /******/ })
  54. /************************************************************************/
  55. /******/ ({
  56. /***/ 1:
  57. /***/ function(module, exports) {
  58. module.exports = require("vue");
  59. /***/ },
  60. /***/ 222:
  61. /***/ function(module, exports, __webpack_require__) {
  62. module.exports = __webpack_require__(30);
  63. /***/ },
  64. /***/ 30:
  65. /***/ function(module, exports, __webpack_require__) {
  66. "use strict";
  67. Object.defineProperty(exports, "__esModule", { value: true });
  68. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_style_empty_css__ = __webpack_require__(5);
  69. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_style_empty_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_style_empty_css__);
  70. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_infinite_scroll_js__ = __webpack_require__(88);
  71. /* harmony reexport (binding) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_1__src_infinite_scroll_js__["a"]; });
  72. /***/ },
  73. /***/ 5:
  74. /***/ function(module, exports) {
  75. // removed by extract-text-webpack-plugin
  76. /***/ },
  77. /***/ 87:
  78. /***/ function(module, exports, __webpack_require__) {
  79. "use strict";
  80. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  81. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  82. var ctx = '@@InfiniteScroll';
  83. var throttle = function(fn, delay) {
  84. var now, lastExec, timer, context, args; //eslint-disable-line
  85. var execute = function() {
  86. fn.apply(context, args);
  87. lastExec = now;
  88. };
  89. return function() {
  90. context = this;
  91. args = arguments;
  92. now = Date.now();
  93. if (timer) {
  94. clearTimeout(timer);
  95. timer = null;
  96. }
  97. if (lastExec) {
  98. var diff = delay - (now - lastExec);
  99. if (diff < 0) {
  100. execute();
  101. } else {
  102. timer = setTimeout(function () {
  103. execute();
  104. }, diff);
  105. }
  106. } else {
  107. execute();
  108. }
  109. };
  110. };
  111. var getScrollTop = function(element) {
  112. if (element === window) {
  113. return Math.max(window.pageYOffset || 0, document.documentElement.scrollTop);
  114. }
  115. return element.scrollTop;
  116. };
  117. var getComputedStyle = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer ? {} : document.defaultView.getComputedStyle;
  118. var getScrollEventTarget = function(element) {
  119. var currentNode = element;
  120. // bugfix, see http://w3help.org/zh-cn/causes/SD9013 and http://stackoverflow.com/questions/17016740/onscroll-function-is-not-working-for-chrome
  121. while (currentNode && currentNode.tagName !== 'HTML' && currentNode.tagName !== 'BODY' && currentNode.nodeType === 1) {
  122. var overflowY = getComputedStyle(currentNode).overflowY;
  123. if (overflowY === 'scroll' || overflowY === 'auto') {
  124. return currentNode;
  125. }
  126. currentNode = currentNode.parentNode;
  127. }
  128. return window;
  129. };
  130. var getVisibleHeight = function(element) {
  131. if (element === window) {
  132. return document.documentElement.clientHeight;
  133. }
  134. return element.clientHeight;
  135. };
  136. var getElementTop = function(element) {
  137. if (element === window) {
  138. return getScrollTop(window);
  139. }
  140. return element.getBoundingClientRect().top + getScrollTop(window);
  141. };
  142. var isAttached = function(element) {
  143. var currentNode = element.parentNode;
  144. while (currentNode) {
  145. if (currentNode.tagName === 'HTML') {
  146. return true;
  147. }
  148. if (currentNode.nodeType === 11) {
  149. return false;
  150. }
  151. currentNode = currentNode.parentNode;
  152. }
  153. return false;
  154. };
  155. var doBind = function() {
  156. if (this.binded) return; // eslint-disable-line
  157. this.binded = true;
  158. var directive = this;
  159. var element = directive.el;
  160. directive.scrollEventTarget = getScrollEventTarget(element);
  161. directive.scrollListener = throttle(doCheck.bind(directive), 200);
  162. directive.scrollEventTarget.addEventListener('scroll', directive.scrollListener);
  163. var disabledExpr = element.getAttribute('infinite-scroll-disabled');
  164. var disabled = false;
  165. if (disabledExpr) {
  166. this.vm.$watch(disabledExpr, function(value) {
  167. directive.disabled = value;
  168. if (!value && directive.immediateCheck) {
  169. doCheck.call(directive);
  170. }
  171. });
  172. disabled = Boolean(directive.vm[disabledExpr]);
  173. }
  174. directive.disabled = disabled;
  175. var distanceExpr = element.getAttribute('infinite-scroll-distance');
  176. var distance = 0;
  177. if (distanceExpr) {
  178. distance = Number(directive.vm[distanceExpr] || distanceExpr);
  179. if (isNaN(distance)) {
  180. distance = 0;
  181. }
  182. }
  183. directive.distance = distance;
  184. var immediateCheckExpr = element.getAttribute('infinite-scroll-immediate-check');
  185. var immediateCheck = true;
  186. if (immediateCheckExpr) {
  187. immediateCheck = Boolean(directive.vm[immediateCheckExpr]);
  188. }
  189. directive.immediateCheck = immediateCheck;
  190. if (immediateCheck) {
  191. doCheck.call(directive);
  192. }
  193. var eventName = element.getAttribute('infinite-scroll-listen-for-event');
  194. if (eventName) {
  195. directive.vm.$on(eventName, function() {
  196. doCheck.call(directive);
  197. });
  198. }
  199. };
  200. var doCheck = function(force) {
  201. var scrollEventTarget = this.scrollEventTarget;
  202. var element = this.el;
  203. var distance = this.distance;
  204. if (force !== true && this.disabled) return; //eslint-disable-line
  205. var viewportScrollTop = getScrollTop(scrollEventTarget);
  206. var viewportBottom = viewportScrollTop + getVisibleHeight(scrollEventTarget);
  207. var shouldTrigger = false;
  208. if (scrollEventTarget === element) {
  209. shouldTrigger = scrollEventTarget.scrollHeight - viewportBottom <= distance;
  210. } else {
  211. var elementBottom = getElementTop(element) - getElementTop(scrollEventTarget) + element.offsetHeight + viewportScrollTop;
  212. shouldTrigger = viewportBottom + distance >= elementBottom;
  213. }
  214. if (shouldTrigger && this.expression) {
  215. this.expression();
  216. }
  217. };
  218. /* harmony default export */ exports["a"] = {
  219. bind: function bind(el, binding, vnode) {
  220. el[ctx] = {
  221. el: el,
  222. vm: vnode.context,
  223. expression: binding.value
  224. };
  225. var args = arguments;
  226. var cb = function() {
  227. el[ctx].vm.$nextTick(function() {
  228. if (isAttached(el)) {
  229. doBind.call(el[ctx], args);
  230. }
  231. el[ctx].bindTryCount = 0;
  232. var tryBind = function() {
  233. if (el[ctx].bindTryCount > 10) return; //eslint-disable-line
  234. el[ctx].bindTryCount++;
  235. if (isAttached(el)) {
  236. doBind.call(el[ctx], args);
  237. } else {
  238. setTimeout(tryBind, 50);
  239. }
  240. };
  241. tryBind();
  242. });
  243. };
  244. if (el[ctx].vm._isMounted) {
  245. cb();
  246. return;
  247. }
  248. el[ctx].vm.$on('hook:mounted', cb);
  249. },
  250. unbind: function unbind(el) {
  251. if (el[ctx] && el[ctx].scrollEventTarget) {
  252. el[ctx].scrollEventTarget.removeEventListener('scroll', el[ctx].scrollListener);
  253. }
  254. }
  255. };
  256. /***/ },
  257. /***/ 88:
  258. /***/ function(module, exports, __webpack_require__) {
  259. "use strict";
  260. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__directive__ = __webpack_require__(87);
  261. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_empty_css__ = __webpack_require__(5);
  262. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_empty_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_mint_ui_src_style_empty_css__);
  263. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_vue__ = __webpack_require__(1);
  264. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_vue__);
  265. var install = function(Vue) {
  266. Vue.directive('InfiniteScroll', __WEBPACK_IMPORTED_MODULE_0__directive__["a" /* default */]);
  267. };
  268. if (!__WEBPACK_IMPORTED_MODULE_2_vue___default.a.prototype.$isServer && window.Vue) {
  269. window.infiniteScroll = __WEBPACK_IMPORTED_MODULE_0__directive__["a" /* default */];
  270. __WEBPACK_IMPORTED_MODULE_2_vue___default.a.use(install); // eslint-disable-line
  271. }
  272. __WEBPACK_IMPORTED_MODULE_0__directive__["a" /* default */].install = install;
  273. /* harmony default export */ exports["a"] = __WEBPACK_IMPORTED_MODULE_0__directive__["a" /* default */];
  274. /***/ }
  275. /******/ });