Skip to content

Commit b4c73a4

Browse files
committed
$mol_list lazy gap support
1 parent 53a52c4 commit b4c73a4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

list/list.view.tree

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $mol_list $mol_view
55
Empty $mol_view
66
Gap_before $mol_view style * paddingTop <= gap_before 0
77
Gap_after $mol_view style * paddingTop <= gap_after 0
8+
item_minimal_height 0 - > 0 for lazy list
89
view_window /
910
0
1011
0

list/list.view.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,28 @@ namespace $.$$ {
103103
}
104104

105105
@ $mol_mem
106-
gap_before() {
107-
const skipped = this.sub().slice( 0 , this.view_window()[0] )
106+
override gap_before() {
107+
const pos = this.view_window()[0]
108+
const item_height = this.item_minimal_height()
109+
if ( item_height ) {
110+
return Math.max(0, pos * item_height)
111+
}
112+
113+
const skipped = this.sub().slice( 0 , pos )
108114
return Math.max( 0 , skipped.reduce( ( sum , view )=> sum + view.minimal_height() , 0 ) )
109115
}
110116

111117
@ $mol_mem
112-
gap_after() {
113-
const skipped = this.sub().slice( this.view_window()[1] )
118+
override gap_after() {
119+
const pos = this.view_window()[1]
120+
121+
const item_height = this.item_minimal_height()
122+
if ( item_height ) {
123+
const count = this.sub().length - pos
124+
return Math.max(0, count * item_height)
125+
}
126+
127+
const skipped = this.sub().slice( pos )
114128
return Math.max( 0 , skipped.reduce( ( sum , view )=> sum + view.minimal_height() , 0 ) )
115129
}
116130

0 commit comments

Comments
 (0)