|
1 | 1 | /*!
|
2 |
| - * vue-virtual-scroll-list v2.3.2 |
| 2 | + * vue-virtual-scroll-list v2.3.3 |
3 | 3 | * open source under the MIT license
|
4 | 4 | * https://github.com/tangbc/vue-virtual-scroll-list#readme
|
5 | 5 | */
|
|
34 | 34 | return Constructor;
|
35 | 35 | }
|
36 | 36 |
|
| 37 | + function _defineProperty(obj, key, value) { |
| 38 | + if (key in obj) { |
| 39 | + Object.defineProperty(obj, key, { |
| 40 | + value: value, |
| 41 | + enumerable: true, |
| 42 | + configurable: true, |
| 43 | + writable: true |
| 44 | + }); |
| 45 | + } else { |
| 46 | + obj[key] = value; |
| 47 | + } |
| 48 | + |
| 49 | + return obj; |
| 50 | + } |
| 51 | + |
| 52 | + function ownKeys(object, enumerableOnly) { |
| 53 | + var keys = Object.keys(object); |
| 54 | + |
| 55 | + if (Object.getOwnPropertySymbols) { |
| 56 | + var symbols = Object.getOwnPropertySymbols(object); |
| 57 | + if (enumerableOnly) symbols = symbols.filter(function (sym) { |
| 58 | + return Object.getOwnPropertyDescriptor(object, sym).enumerable; |
| 59 | + }); |
| 60 | + keys.push.apply(keys, symbols); |
| 61 | + } |
| 62 | + |
| 63 | + return keys; |
| 64 | + } |
| 65 | + |
| 66 | + function _objectSpread2(target) { |
| 67 | + for (var i = 1; i < arguments.length; i++) { |
| 68 | + var source = arguments[i] != null ? arguments[i] : {}; |
| 69 | + |
| 70 | + if (i % 2) { |
| 71 | + ownKeys(Object(source), true).forEach(function (key) { |
| 72 | + _defineProperty(target, key, source[key]); |
| 73 | + }); |
| 74 | + } else if (Object.getOwnPropertyDescriptors) { |
| 75 | + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); |
| 76 | + } else { |
| 77 | + ownKeys(Object(source)).forEach(function (key) { |
| 78 | + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); |
| 79 | + }); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + return target; |
| 84 | + } |
| 85 | + |
37 | 86 | function _toConsumableArray(arr) {
|
38 | 87 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
39 | 88 | }
|
|
81 | 130 | FIXED: 'FIXED',
|
82 | 131 | DYNAMIC: 'DYNAMIC'
|
83 | 132 | };
|
84 |
| - var LEADING_BUFFER = 2; |
| 133 | + var LEADING_BUFFER = 0; |
85 | 134 |
|
86 | 135 | var Virtual = /*#__PURE__*/function () {
|
87 | 136 | function Virtual(param, callUpdate) {
|
|
536 | 585 | component: {
|
537 | 586 | type: [Object, Function]
|
538 | 587 | },
|
| 588 | + slotComponent: { |
| 589 | + type: Function |
| 590 | + }, |
539 | 591 | uniqueKey: {
|
540 | 592 | type: [String, Number]
|
541 | 593 | },
|
|
561 | 613 | }
|
562 | 614 | };
|
563 | 615 |
|
564 |
| - /** |
565 |
| - * item and slot component both use similar wrapper |
566 |
| - * we need to know their size change at any time |
567 |
| - */ |
568 | 616 | var Wrapper = {
|
569 | 617 | created: function created() {
|
570 | 618 | this.shapeKey = this.horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
609 | 657 | _this$extraProps = this.extraProps,
|
610 | 658 | extraProps = _this$extraProps === void 0 ? {} : _this$extraProps,
|
611 | 659 | index = this.index,
|
| 660 | + source = this.source, |
612 | 661 | _this$scopedSlots = this.scopedSlots,
|
613 | 662 | scopedSlots = _this$scopedSlots === void 0 ? {} : _this$scopedSlots,
|
614 |
| - uniqueKey = this.uniqueKey; |
615 |
| - extraProps.source = this.source; |
616 |
| - extraProps.index = index; |
| 663 | + uniqueKey = this.uniqueKey, |
| 664 | + slotComponent = this.slotComponent; |
| 665 | + |
| 666 | + var props = _objectSpread2({}, extraProps, { |
| 667 | + source: source, |
| 668 | + index: index |
| 669 | + }); |
| 670 | + |
617 | 671 | return h(tag, {
|
618 | 672 | key: uniqueKey,
|
619 | 673 | attrs: {
|
620 | 674 | role: 'listitem'
|
621 | 675 | }
|
622 |
| - }, [h(component, { |
623 |
| - props: extraProps, |
| 676 | + }, [slotComponent ? h('div', slotComponent({ |
| 677 | + item: source, |
| 678 | + index: index, |
| 679 | + scope: props |
| 680 | + })) : h(component, { |
| 681 | + props: props, |
624 | 682 | scopedSlots: scopedSlots
|
625 | 683 | })]);
|
626 | 684 | }
|
|
649 | 707 | SLOT: 'slot_resize'
|
650 | 708 | };
|
651 | 709 | var SLOT_TYPE = {
|
652 |
| - HEADER: 'header', |
| 710 | + HEADER: 'thead', |
653 | 711 | // string value also use for aria role attribute
|
654 |
| - FOOTER: 'footer' |
| 712 | + FOOTER: 'tfoot' |
655 | 713 | };
|
656 | 714 | var VirtualList = Vue.component('virtual-list', {
|
657 | 715 | props: VirtualProps,
|
|
894 | 952 | extraProps = this.extraProps,
|
895 | 953 | dataComponent = this.dataComponent,
|
896 | 954 | itemScopedSlots = this.itemScopedSlots;
|
| 955 | + var slotComponent = this.$scopedSlots && this.$scopedSlots.item; |
897 | 956 |
|
898 | 957 | for (var index = start; index <= end; index++) {
|
899 | 958 | var dataSource = dataSources[index];
|
|
912 | 971 | source: dataSource,
|
913 | 972 | extraProps: extraProps,
|
914 | 973 | component: dataComponent,
|
| 974 | + slotComponent: slotComponent, |
915 | 975 | scopedSlots: itemScopedSlots
|
916 | 976 | },
|
917 | 977 | style: itemStyle,
|
|
0 commit comments