Skip to content

Commit 24997c6

Browse files
author
Daniel
authored
Merge pull request #137 from gurupras/1.x
Added virtualLines prop to control number of visible lines
2 parents e7c81f7 + f78e9f7 commit 24997c6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ plugins: [
112112
| showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |
113113
| virtual | normal | Whether to use virtual scrolling, usually used for big data | boolean | false |
114114
| itemHeight | normal | The height of each item when using virtual scrolling | number | auto |
115+
| virtualLines | normal | The number of lines to render when virtual scrolling is enabled | number | 10 |
115116
| v-model | higher | Defines value when the tree can be selected | string, array | - |
116117
| path | higher | Root data path | string | root |
117118
| pathSelectable | higher | Defines whether a data path supports selection | function(path, content) | - |

src/components/Tree/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export default {
127127
type: Function,
128128
default: null,
129129
},
130+
// Number of lines to show when virtual is true
131+
virtualLines: {
132+
type: Number,
133+
default: 10
134+
}
130135
},
131136
data() {
132137
return {
@@ -217,7 +222,7 @@ export default {
217222
methods: {
218223
onTreeScroll() {
219224
if (this.virtual) {
220-
const visibleCount = 10;
225+
const visibleCount = this.virtualLines;
221226
const scrollTop = (this.$refs.tree && this.$refs.tree.scrollTop) || 0;
222227
const scrollCount = Math.floor(scrollTop / this.itemHeight);
223228
let start =

0 commit comments

Comments
 (0)