cbvirtua 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/floating/components/Popper.js +1011 -0
- package/floating/components/PopperMethods.js +17 -0
- package/floating/components/ThemeClass.js +9 -0
- package/floating/config.js +133 -0
- package/floating/demo/TestDropdown.vue +22 -0
- package/floating/demo/TestSubMenu.vue +87 -0
- package/floating/demo/TestTooltip.vue +19 -0
- package/floating/directives/v-close-popper.js +67 -0
- package/floating/directives/v-tooltip.js +116 -0
- package/floating/directives/v-tooltip.spec.js +28 -0
- package/floating/index.js +74 -0
- package/floating/util/assign-deep.js +12 -0
- package/floating/util/env.js +18 -0
- package/floating/util/events.js +12 -0
- package/floating/util/frame.js +5 -0
- package/floating/util/lang.js +6 -0
- package/floating/util/popper.js +5 -0
- package/package.json +1 -1
- package/vue2/VList.js +55 -55
package/vue2/VList.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { SCROLL_IDLE, UPDATE_SCROLL_STATE, UPDATE_SCROLL_EVENT, UPDATE_SCROLL_END_EVENT, UPDATE_SIZE_STATE, overscanEndIndex, overscanStartIndex, createVirtualStore, ACTION_ITEMS_LENGTH_CHANGE, getScrollSize, getMinContainerSize, } from "../core/store"
|
|
2
|
-
import { createResizer } from "../core/resizer"
|
|
3
|
-
import { createScroller } from "../core/scroller"
|
|
4
|
-
import { default as ListItem } from "./ListItem"
|
|
5
|
-
import { exists } from "../core/utils"
|
|
1
|
+
import { SCROLL_IDLE, UPDATE_SCROLL_STATE, UPDATE_SCROLL_EVENT, UPDATE_SCROLL_END_EVENT, UPDATE_SIZE_STATE, overscanEndIndex, overscanStartIndex, createVirtualStore, ACTION_ITEMS_LENGTH_CHANGE, getScrollSize, getMinContainerSize, } from "../core/store"
|
|
2
|
+
import { createResizer } from "../core/resizer"
|
|
3
|
+
import { createScroller } from "../core/scroller"
|
|
4
|
+
import { default as ListItem } from "./ListItem"
|
|
5
|
+
import { exists } from "../core/utils"
|
|
6
6
|
const props = {
|
|
7
7
|
data: { type: Array, required: true },
|
|
8
8
|
overscan: { type: Number, default: 4 },
|
|
9
9
|
itemSize: Number,
|
|
10
10
|
shift: Boolean,
|
|
11
11
|
horizontal: Boolean,
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
export default {
|
|
14
14
|
props: props,
|
|
15
15
|
data() {
|
|
@@ -22,91 +22,91 @@ export default {
|
|
|
22
22
|
},
|
|
23
23
|
watch: {
|
|
24
24
|
data(_data) {
|
|
25
|
-
const count = _data.length
|
|
26
|
-
this.store._update(ACTION_ITEMS_LENGTH_CHANGE, [count, this.shift])
|
|
25
|
+
const count = _data.length
|
|
26
|
+
this.store._update(ACTION_ITEMS_LENGTH_CHANGE, [count, this.shift])
|
|
27
27
|
},
|
|
28
28
|
JumpCount(count, prevCount) {
|
|
29
29
|
this.$nextTick(() => {
|
|
30
30
|
if (count === prevCount)
|
|
31
|
-
return
|
|
32
|
-
const jump = this.store._flushJump()
|
|
31
|
+
return
|
|
32
|
+
const jump = this.store._flushJump()
|
|
33
33
|
if (!jump)
|
|
34
|
-
return
|
|
35
|
-
this.scroller._fixScrollJump(jump)
|
|
34
|
+
return
|
|
35
|
+
this.scroller._fixScrollJump(jump)
|
|
36
36
|
})
|
|
37
37
|
},
|
|
38
38
|
range([start, end], [prevStart, prevEnd]) {
|
|
39
39
|
this.$nextTick(() => {
|
|
40
40
|
if (prevStart === start && prevEnd === end)
|
|
41
|
-
return
|
|
42
|
-
this.$emit("rangeChange", start, end)
|
|
41
|
+
return
|
|
42
|
+
this.$emit("rangeChange", start, end)
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
},
|
|
47
47
|
created() {
|
|
48
|
-
const isHorizontal = this.horizontal
|
|
48
|
+
const isHorizontal = this.horizontal
|
|
49
49
|
const store = this.store = createVirtualStore(
|
|
50
50
|
this.data.length,
|
|
51
51
|
this.itemSize ?? 40,
|
|
52
52
|
undefined,
|
|
53
53
|
undefined,
|
|
54
54
|
!this.itemSize
|
|
55
|
-
)
|
|
56
|
-
const resizer = this.resizer = createResizer(store, isHorizontal)
|
|
57
|
-
const scroller = this.scroller = createScroller(store, isHorizontal)
|
|
58
|
-
this.scrollToIndex = scroller._scrollToIndex
|
|
59
|
-
this.scrollTo = scroller._scrollTo
|
|
60
|
-
this.scrollBy = scroller._scrollBy
|
|
61
|
-
const rerender = store._getStateVersion()
|
|
55
|
+
)
|
|
56
|
+
const resizer = this.resizer = createResizer(store, isHorizontal)
|
|
57
|
+
const scroller = this.scroller = createScroller(store, isHorizontal)
|
|
58
|
+
this.scrollToIndex = scroller._scrollToIndex
|
|
59
|
+
this.scrollTo = scroller._scrollTo
|
|
60
|
+
this.scrollBy = scroller._scrollBy
|
|
61
|
+
const rerender = store._getStateVersion()
|
|
62
62
|
const unsubscribeStore = this.unsubscribeStore = store._subscribe(UPDATE_SCROLL_STATE + UPDATE_SIZE_STATE, () => {
|
|
63
|
-
this.rerender = store._getStateVersion()
|
|
64
|
-
this.JumpCount = store._getJumpCount()
|
|
65
|
-
|
|
63
|
+
this.rerender = store._getStateVersion()
|
|
64
|
+
this.JumpCount = store._getJumpCount()
|
|
65
|
+
this.range = store._getRange()
|
|
66
|
+
})
|
|
66
67
|
const unsubscribeOnScroll = this.unsubscribeOnScroll = store._subscribe(UPDATE_SCROLL_EVENT, () => {
|
|
67
|
-
this.$emit("scroll", store._getScrollOffset())
|
|
68
|
-
})
|
|
68
|
+
this.$emit("scroll", store._getScrollOffset())
|
|
69
|
+
})
|
|
69
70
|
const unsubscribeOnScrollEnd = this.unsubscribeOnScrollEnd = store._subscribe(UPDATE_SCROLL_END_EVENT, () => {
|
|
70
|
-
this.$emit("scrollEnd")
|
|
71
|
-
})
|
|
71
|
+
this.$emit("scrollEnd")
|
|
72
|
+
})
|
|
72
73
|
},
|
|
73
74
|
mounted() {
|
|
74
|
-
const root = this.$refs.root
|
|
75
|
+
const root = this.$refs.root
|
|
75
76
|
if (!root)
|
|
76
|
-
return
|
|
77
|
-
this.resizer._observeRoot(root)
|
|
78
|
-
this.scroller._observe(root)
|
|
77
|
+
return
|
|
78
|
+
this.resizer._observeRoot(root)
|
|
79
|
+
this.scroller._observe(root)
|
|
79
80
|
|
|
80
81
|
},
|
|
81
82
|
methods: {
|
|
82
83
|
scrollOffset() {
|
|
83
|
-
return this.store._getScrollOffset()
|
|
84
|
+
return this.store._getScrollOffset()
|
|
84
85
|
},
|
|
85
86
|
scrollSize() {
|
|
86
|
-
return this.getScrollSize(store)
|
|
87
|
+
return this.getScrollSize(store)
|
|
87
88
|
},
|
|
88
89
|
viewportSize() {
|
|
89
|
-
return this.store._getViewportSize()
|
|
90
|
+
return this.store._getViewportSize()
|
|
90
91
|
},
|
|
91
92
|
scrollToIndex() { },
|
|
92
93
|
scrollTo() { },
|
|
93
94
|
scrollBy() { }
|
|
94
95
|
},
|
|
95
96
|
render() {
|
|
96
|
-
this.rerender
|
|
97
|
-
const count = this.data.length
|
|
98
|
-
const store = this.store
|
|
99
|
-
const isHorizontal = this.horizontal
|
|
100
|
-
const [startIndex, endIndex] = this.store._getRange()
|
|
101
|
-
const scrollDirection = store._getScrollDirection()
|
|
102
|
-
const totalSize = store._getTotalSize()
|
|
103
|
-
|
|
104
|
-
const minSize = getMinContainerSize(store);
|
|
97
|
+
this.rerender
|
|
98
|
+
const count = this.data.length
|
|
99
|
+
const store = this.store
|
|
100
|
+
const isHorizontal = this.horizontal
|
|
101
|
+
const [startIndex, endIndex] = this.store._getRange()
|
|
102
|
+
const scrollDirection = store._getScrollDirection()
|
|
103
|
+
const totalSize = store._getTotalSize()
|
|
104
|
+
const minSize = getMinContainerSize(store)
|
|
105
105
|
|
|
106
|
-
const items = []
|
|
106
|
+
const items = []
|
|
107
107
|
for (let i = overscanStartIndex(startIndex, this.overscan, scrollDirection), j = overscanEndIndex(endIndex, this.overscan, scrollDirection, count); i <= j; i++) {
|
|
108
|
-
const e = this.$scopedSlots.default(this.data[i])[0]
|
|
109
|
-
const key = e.key
|
|
108
|
+
const e = this.$scopedSlots.default(this.data[i])[0]
|
|
109
|
+
const key = e.key
|
|
110
110
|
items.push(
|
|
111
111
|
<ListItem
|
|
112
112
|
key={exists(key) ? key : "_" + i}
|
|
@@ -118,7 +118,7 @@ export default {
|
|
|
118
118
|
children={e}
|
|
119
119
|
isHorizontal={isHorizontal}
|
|
120
120
|
/>
|
|
121
|
-
)
|
|
121
|
+
)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
return (
|
|
@@ -149,13 +149,13 @@ export default {
|
|
|
149
149
|
{items}
|
|
150
150
|
</div>
|
|
151
151
|
</div>
|
|
152
|
-
)
|
|
152
|
+
)
|
|
153
153
|
},
|
|
154
154
|
destoryed() {
|
|
155
|
-
this.unsubscribeStore()
|
|
156
|
-
this.unsubscribeOnScroll()
|
|
157
|
-
this.unsubscribeOnScrollEnd()
|
|
158
|
-
this.resizer._dispose()
|
|
159
|
-
this.scroller._dispose()
|
|
155
|
+
this.unsubscribeStore()
|
|
156
|
+
this.unsubscribeOnScroll()
|
|
157
|
+
this.unsubscribeOnScrollEnd()
|
|
158
|
+
this.resizer._dispose()
|
|
159
|
+
this.scroller._dispose()
|
|
160
160
|
},
|
|
161
161
|
}
|