Skip to content

Commit 5bfdf72

Browse files
authored
Merge pull request #10 from FallingCeilingS/v0.1.x/expose-apis
Expose apis
2 parents afde411 + 058044c commit 5bfdf72

File tree

7 files changed

+40
-10
lines changed

7 files changed

+40
-10
lines changed

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ examples
44
.editorconfig
55
babel.config.js
66
.eslintrc.js
7+
babel.config.js
8+
tsconfig.json
9+
vue.config.js
710
*.gif
8-
*.log
11+
*.log
12+
*.lock

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
> Vue components developed by [Vue.js 3.0](https://v3.vuejs.org/) for efficiently rendering large scrollable lists and hierarchical data. `vue-virtualised` is able to render and update 1 million nodes within a few seconds in front-end.
88
9-
![Demo](/src/assets/demo-20200415.gif)
9+
![Demo](/src/assets/demo-20200419.gif)
1010

1111
## Getting started
1212

@@ -191,7 +191,7 @@ scrollToHeight(height: number, behaviour: ScrollBehavior): void
191191
#### `createNode()`
192192

193193
```ts
194-
createNode(nodes: Array<Node | NodeModel>, node: NodeModel, path: Array<number>): void
194+
createNode(nodes: Array<Node | NodeModel>, node: NodeModel, path: Array<number>): Promise<void>
195195
```
196196

197197
This method creates a single node (node allows contain children) as well as its descendants, and it can be bound to the `cell` slot. Valid parameters are:
@@ -264,6 +264,14 @@ This method removes a single node as well as its descendants, and it can be boun
264264
- `nodes`: `nodes` prop.
265265
- `path`: The path of the node in the tree structure.
266266

267+
#### `forceUpdate()`
268+
269+
```ts
270+
forceUpdate(): void
271+
```
272+
273+
Forces refresh rendered content.
274+
267275
## Contributing
268276

269277
Pull requests and issues are welcome!

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtualised",
3-
"version": "0.1.0-4",
3+
"version": "0.1.0",
44
"private": false,
55
"description": "Vue components developed by Vue.js 3.0 for efficiently rendering large scrollable lists and hierarchical data. vue-virtualised is able to render and update 1 million nodes within a few seconds in front-end.",
66
"author": {

src/assets/demo-20200331-60fps.gif

-12 MB
Binary file not shown.

src/assets/demo-20200409.gif

-7.64 MB
Binary file not shown.

src/assets/demo-20200419.gif

6.01 MB
Loading

src/components/VirtualisedList.vue

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
import { defineComponent, PropType, ref, onMounted } from "vue";
2727
import VirtualisedBaseScroller from "./Base/VirtualisedBaseScroller.vue";
2828
29-
import { GetNodeHeight, GetNodeKey, CellRenderer } from "../types/types";
29+
import {
30+
GetNodeHeight,
31+
GetNodeKey,
32+
CellRenderer,
33+
ConditionCallback,
34+
} from "../types/types";
3035
3136
export default defineComponent({
3237
name: "VirtualisedList",
@@ -73,11 +78,20 @@ export default defineComponent({
7378
emits: ["onScroll", "onStartReached", "onEndReached"],
7479
setup(props, { emit }) {
7580
const scroller = ref<typeof VirtualisedBaseScroller | null>(null);
76-
const scrollToStart = ref(null);
77-
const scrollToEnd = ref(null);
78-
const scrollToIndex = ref(null);
79-
const scrollToNode = ref(null);
80-
const refreshView = ref(null);
81+
const getScrollTop = ref<(() => number) | null>(null);
82+
const scrollToStart = ref<(() => void) | null>(null);
83+
const scrollToEnd = ref<(() => void) | null>(null);
84+
const scrollToHeight = ref<
85+
// eslint-disable-next-line no-unused-vars, no-undef
86+
((height: number, behaviour?: ScrollBehavior) => void) | null
87+
>(null);
88+
// eslint-disable-next-line no-unused-vars
89+
const scrollToIndex = ref<((index: number) => void) | null>(null);
90+
const scrollToNode = ref<
91+
// eslint-disable-next-line no-unused-vars
92+
((conditionCallback: ConditionCallback) => void) | null
93+
>(null);
94+
const refreshView = ref<(() => void) | null>(null);
8195
8296
const handleScroll = (scrollTop: number): void => {
8397
emit("onScroll", scrollTop);
@@ -92,17 +106,21 @@ export default defineComponent({
92106
};
93107
94108
onMounted(() => {
109+
getScrollTop.value = scroller.value?.getScrollTop;
95110
scrollToStart.value = scroller.value?.scrollToStart;
96111
scrollToEnd.value = scroller.value?.scrollToEnd;
112+
scrollToHeight.value = scroller.value?.scrollToHeight;
97113
scrollToIndex.value = scroller.value?.scrollToIndex;
98114
scrollToNode.value = scroller.value?.scrollToNode;
99115
refreshView.value = scroller.value?.refreshView;
100116
});
101117
102118
return {
103119
scroller,
120+
getScrollTop,
104121
scrollToStart,
105122
scrollToEnd,
123+
scrollToHeight,
106124
scrollToIndex,
107125
scrollToNode,
108126
handleScroll,

0 commit comments

Comments
 (0)