list add findVisibleItems api

This commit is contained in:
pengfei.zhou
2021-10-11 18:02:56 +08:00
committed by osborn
parent 0e77c62e13
commit 8fd2477c81
4 changed files with 132 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
import { Stack } from './layouts'
import { Property, Superview, View, NativeViewModel } from '../ui/view'
import { layoutConfig } from '../util/index.util'
import { BridgeContext } from '../..'
export class FlowLayoutItem extends Stack {
/**
@@ -94,6 +95,21 @@ export class FlowLayout extends Superview {
@Property
footer?: FlowLayoutItem
/**
* @param context
* @returns Returns the range of the visible views for each column.
*/
findVisibleItems(context: BridgeContext) {
return this.nativeChannel(context, 'findVisibleItems')() as Promise<{ first: number, last: number }[]>
}
/**
* @param context
* @returns Returns the range of the completely visible views for each column.
*/
findCompletelyVisibleItems(context: BridgeContext) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')() as Promise<{ first: number, last: number }[]>
}
reset() {
this.cachedViews.clear()

View File

@@ -35,6 +35,12 @@ export class ListItem extends Stack {
}[]
}
export enum OtherItems {
LoadMore = -10,
Header = -11,
Footer = -12,
}
export class List extends Superview {
private cachedViews: Map<string, ListItem> = new Map
@@ -97,6 +103,20 @@ export class List extends Superview {
const animated = config?.animated
return this.nativeChannel(context, 'scrollToItem')({ index, animated, }) as Promise<any>
}
/**
* @param context
* @returns Returns the range of the visible views.
*/
findVisibleItems(context: BridgeContext) {
return this.nativeChannel(context, 'findVisibleItems')() as Promise<{ first: number, last: number }>
}
/**
* @param context
* @returns Returns the range of the completely visible views.
*/
findCompletelyVisibleItems(context: BridgeContext) {
return this.nativeChannel(context, 'findCompletelyVisibleItems')() as Promise<{ first: number, last: number }>
}
reset() {
this.cachedViews.clear()