框架源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

422 lines
12 KiB

4 years ago
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 66);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, exports) {
  91. module.exports = require("tis-ui/lib/utils/util");
  92. /***/ }),
  93. /***/ 44:
  94. /***/ (function(module, exports) {
  95. module.exports = require("tis-ui/lib/utils/resize-event");
  96. /***/ }),
  97. /***/ 65:
  98. /***/ (function(module, exports) {
  99. module.exports = require("tis-ui/lib/utils/scrollbar-width");
  100. /***/ }),
  101. /***/ 66:
  102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103. "use strict";
  104. // ESM COMPAT FLAG
  105. __webpack_require__.r(__webpack_exports__);
  106. // EXTERNAL MODULE: external "tis-ui/lib/utils/resize-event"
  107. var resize_event_ = __webpack_require__(44);
  108. // EXTERNAL MODULE: external "tis-ui/lib/utils/scrollbar-width"
  109. var scrollbar_width_ = __webpack_require__(65);
  110. var scrollbar_width_default = /*#__PURE__*/__webpack_require__.n(scrollbar_width_);
  111. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  112. var util_ = __webpack_require__(10);
  113. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  114. var dom_ = __webpack_require__(7);
  115. // CONCATENATED MODULE: ./packages/scrollbar/src/util.js
  116. var BAR_MAP = {
  117. vertical: {
  118. offset: 'offsetHeight',
  119. scroll: 'scrollTop',
  120. scrollSize: 'scrollHeight',
  121. size: 'height',
  122. key: 'vertical',
  123. axis: 'Y',
  124. client: 'clientY',
  125. direction: 'top'
  126. },
  127. horizontal: {
  128. offset: 'offsetWidth',
  129. scroll: 'scrollLeft',
  130. scrollSize: 'scrollWidth',
  131. size: 'width',
  132. key: 'horizontal',
  133. axis: 'X',
  134. client: 'clientX',
  135. direction: 'left'
  136. }
  137. };
  138. function renderThumbStyle(_ref) {
  139. var move = _ref.move,
  140. size = _ref.size,
  141. bar = _ref.bar;
  142. var style = {};
  143. var translate = 'translate' + bar.axis + '(' + move + '%)';
  144. style[bar.size] = size;
  145. style.transform = translate;
  146. style.msTransform = translate;
  147. style.webkitTransform = translate;
  148. return style;
  149. };
  150. // CONCATENATED MODULE: ./packages/scrollbar/src/bar.js
  151. /* istanbul ignore next */
  152. /* harmony default export */ var src_bar = ({
  153. name: 'Bar',
  154. props: {
  155. vertical: Boolean,
  156. size: String,
  157. move: Number
  158. },
  159. computed: {
  160. bar: function bar() {
  161. return BAR_MAP[this.vertical ? 'vertical' : 'horizontal'];
  162. },
  163. wrap: function wrap() {
  164. return this.$parent.wrap;
  165. }
  166. },
  167. render: function render(h) {
  168. var size = this.size,
  169. move = this.move,
  170. bar = this.bar;
  171. return h(
  172. 'div',
  173. {
  174. 'class': ['el-scrollbar__bar', 'is-' + bar.key],
  175. on: {
  176. 'mousedown': this.clickTrackHandler
  177. }
  178. },
  179. [h('div', {
  180. ref: 'thumb',
  181. 'class': 'el-scrollbar__thumb',
  182. on: {
  183. 'mousedown': this.clickThumbHandler
  184. },
  185. style: renderThumbStyle({ size: size, move: move, bar: bar }) })]
  186. );
  187. },
  188. methods: {
  189. clickThumbHandler: function clickThumbHandler(e) {
  190. // prevent click event of right button
  191. if (e.ctrlKey || e.button === 2) {
  192. return;
  193. }
  194. this.startDrag(e);
  195. this[this.bar.axis] = e.currentTarget[this.bar.offset] - (e[this.bar.client] - e.currentTarget.getBoundingClientRect()[this.bar.direction]);
  196. },
  197. clickTrackHandler: function clickTrackHandler(e) {
  198. var offset = Math.abs(e.target.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]);
  199. var thumbHalf = this.$refs.thumb[this.bar.offset] / 2;
  200. var thumbPositionPercentage = (offset - thumbHalf) * 100 / this.$el[this.bar.offset];
  201. this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
  202. },
  203. startDrag: function startDrag(e) {
  204. e.stopImmediatePropagation();
  205. this.cursorDown = true;
  206. Object(dom_["on"])(document, 'mousemove', this.mouseMoveDocumentHandler);
  207. Object(dom_["on"])(document, 'mouseup', this.mouseUpDocumentHandler);
  208. document.onselectstart = function () {
  209. return false;
  210. };
  211. },
  212. mouseMoveDocumentHandler: function mouseMoveDocumentHandler(e) {
  213. if (this.cursorDown === false) return;
  214. var prevPage = this[this.bar.axis];
  215. if (!prevPage) return;
  216. var offset = (this.$el.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]) * -1;
  217. var thumbClickPosition = this.$refs.thumb[this.bar.offset] - prevPage;
  218. var thumbPositionPercentage = (offset - thumbClickPosition) * 100 / this.$el[this.bar.offset];
  219. this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
  220. },
  221. mouseUpDocumentHandler: function mouseUpDocumentHandler(e) {
  222. this.cursorDown = false;
  223. this[this.bar.axis] = 0;
  224. Object(dom_["off"])(document, 'mousemove', this.mouseMoveDocumentHandler);
  225. document.onselectstart = null;
  226. }
  227. },
  228. destroyed: function destroyed() {
  229. Object(dom_["off"])(document, 'mouseup', this.mouseUpDocumentHandler);
  230. }
  231. });
  232. // CONCATENATED MODULE: ./packages/scrollbar/src/main.js
  233. // reference https://github.com/noeldelgado/gemini-scrollbar/blob/master/index.js
  234. /* istanbul ignore next */
  235. /* harmony default export */ var main = ({
  236. name: 'TisScrollbar',
  237. components: { Bar: src_bar },
  238. props: {
  239. native: Boolean,
  240. wrapStyle: {},
  241. wrapClass: {},
  242. viewClass: {},
  243. viewStyle: {},
  244. noresize: Boolean, // 如果 container 尺寸不会发生变化,最好设置它可以优化性能
  245. tag: {
  246. type: String,
  247. default: 'div'
  248. }
  249. },
  250. data: function data() {
  251. return {
  252. sizeWidth: '0',
  253. sizeHeight: '0',
  254. moveX: 0,
  255. moveY: 0
  256. };
  257. },
  258. computed: {
  259. wrap: function wrap() {
  260. return this.$refs.wrap;
  261. }
  262. },
  263. render: function render(h) {
  264. var gutter = scrollbar_width_default()();
  265. var style = this.wrapStyle;
  266. if (gutter) {
  267. var gutterWith = '-' + gutter + 'px';
  268. var gutterStyle = 'margin-bottom: ' + gutterWith + '; margin-right: ' + gutterWith + ';';
  269. if (Array.isArray(this.wrapStyle)) {
  270. style = Object(util_["toObject"])(this.wrapStyle);
  271. style.marginRight = style.marginBottom = gutterWith;
  272. } else if (typeof this.wrapStyle === 'string') {
  273. style += gutterStyle;
  274. } else {
  275. style = gutterStyle;
  276. }
  277. }
  278. var view = h(this.tag, {
  279. class: ['el-scrollbar__view', this.viewClass],
  280. style: this.viewStyle,
  281. ref: 'resize'
  282. }, this.$slots.default);
  283. var wrap = h(
  284. 'div',
  285. {
  286. ref: 'wrap',
  287. style: style,
  288. on: {
  289. 'scroll': this.handleScroll
  290. },
  291. 'class': [this.wrapClass, 'el-scrollbar__wrap', gutter ? '' : 'el-scrollbar__wrap--hidden-default'] },
  292. [[view]]
  293. );
  294. var nodes = void 0;
  295. if (!this.native) {
  296. nodes = [wrap, h(src_bar, {
  297. attrs: {
  298. move: this.moveX,
  299. size: this.sizeWidth }
  300. }), h(src_bar, {
  301. attrs: {
  302. vertical: true,
  303. move: this.moveY,
  304. size: this.sizeHeight }
  305. })];
  306. } else {
  307. nodes = [h(
  308. 'div',
  309. {
  310. ref: 'wrap',
  311. 'class': [this.wrapClass, 'el-scrollbar__wrap'],
  312. style: style },
  313. [[view]]
  314. )];
  315. }
  316. return h('div', { class: 'el-scrollbar' }, nodes);
  317. },
  318. methods: {
  319. handleScroll: function handleScroll() {
  320. var wrap = this.wrap;
  321. this.moveY = wrap.scrollTop * 100 / wrap.clientHeight;
  322. this.moveX = wrap.scrollLeft * 100 / wrap.clientWidth;
  323. },
  324. update: function update() {
  325. var heightPercentage = void 0,
  326. widthPercentage = void 0;
  327. var wrap = this.wrap;
  328. if (!wrap) return;
  329. heightPercentage = wrap.clientHeight * 100 / wrap.scrollHeight;
  330. widthPercentage = wrap.clientWidth * 100 / wrap.scrollWidth;
  331. this.sizeHeight = heightPercentage < 100 ? heightPercentage + '%' : '';
  332. this.sizeWidth = widthPercentage < 100 ? widthPercentage + '%' : '';
  333. }
  334. },
  335. mounted: function mounted() {
  336. if (this.native) return;
  337. this.$nextTick(this.update);
  338. !this.noresize && Object(resize_event_["addResizeListener"])(this.$refs.resize, this.update);
  339. },
  340. beforeDestroy: function beforeDestroy() {
  341. if (this.native) return;
  342. !this.noresize && Object(resize_event_["removeResizeListener"])(this.$refs.resize, this.update);
  343. }
  344. });
  345. // CONCATENATED MODULE: ./packages/scrollbar/index.js
  346. /* istanbul ignore next */
  347. main.install = function (Vue) {
  348. Vue.component(main.name, main);
  349. };
  350. /* harmony default export */ var scrollbar = __webpack_exports__["default"] = (main);
  351. /***/ }),
  352. /***/ 7:
  353. /***/ (function(module, exports) {
  354. module.exports = require("tis-ui/lib/utils/dom");
  355. /***/ })
  356. /******/ });