@@ -180,31 +180,79 @@ BlInfiniteLinearLayout >> computeHorizontalScrollRange [
180
180
{ #category : #' private - scrolling' }
181
181
BlInfiniteLinearLayout >> computeScrollExtent [
182
182
< return: #Number >
183
-
184
- self hasChildren
185
- ifFalse: [ ^ 0 ].
186
-
187
- ^ self createScrollbarHelper computeScrollExtent
183
+ | anExtent startElement endElement |
184
+ self hasChildren ifFalse: [ ^ 0 ].
185
+
186
+ startElement := self
187
+ findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
188
+ acceptPartiallyVisible: true .
189
+ endElement := self
190
+ findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
191
+ acceptPartiallyVisible: true .
192
+
193
+ anExtent := (orientation decoratedEnd: endElement)
194
+ - (orientation decoratedStart: startElement).
195
+
196
+ ^ orientation totalSpace min: anExtent
188
197
]
189
198
190
199
{ #category : #' private - scrolling' }
191
200
BlInfiniteLinearLayout >> computeScrollOffset [
192
201
< return: #Number >
193
-
194
- self hasChildren
195
- ifFalse: [ ^ 0 ].
196
-
197
- ^ self createScrollbarHelper computeScrollOffset
202
+ | startPosition endPosition minPosition maxPosition itemsBefore laidOutArea itemRange avgSizePerRow startElement endElement |
203
+ self hasChildren ifFalse: [ ^ 0 ].
204
+
205
+ startElement := self
206
+ findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
207
+ acceptPartiallyVisible: true .
208
+ endElement := self
209
+ findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
210
+ acceptPartiallyVisible: true .
211
+
212
+ startPosition := self childPositionOf: startElement.
213
+ endPosition := self childPositionOf: endElement.
214
+
215
+ minPosition := startPosition min: endPosition.
216
+ maxPosition := startPosition max: endPosition.
217
+
218
+ itemsBefore := 0
219
+ max: (shouldReverseLayout
220
+ ifTrue: [ self state itemCount - maxPosition - 1 ]
221
+ ifFalse: [ minPosition - 1 ]).
222
+
223
+ smoothScrollbarEnabled ifFalse: [ ^ itemsBefore ].
224
+
225
+ laidOutArea := ((orientation decoratedEnd: endElement)
226
+ - (orientation decoratedStart: startElement)) abs.
227
+ itemRange := (startPosition - endPosition) abs + 1 .
228
+ avgSizePerRow := (laidOutArea / itemRange) asFloat.
229
+
230
+ ^ itemsBefore * avgSizePerRow
231
+ + (orientation startWithPadding - (orientation decoratedStart: startElement))
198
232
]
199
233
200
234
{ #category : #' private - scrolling' }
201
235
BlInfiniteLinearLayout >> computeScrollRange [
202
236
< return: #Number >
203
-
204
- self hasChildren
205
- ifFalse: [ ^ 0 ].
206
-
207
- ^ self createScrollbarHelper computeScrollRange
237
+ | laidOutArea startElement endElement laidOutRange |
238
+ self hasChildren ifFalse: [ ^ 0 ].
239
+
240
+ smoothScrollbarEnabled ifFalse: [ ^ self state itemCount ].
241
+
242
+ startElement := self
243
+ findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
244
+ acceptPartiallyVisible: true .
245
+ endElement := self
246
+ findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
247
+ acceptPartiallyVisible: true .
248
+
249
+ laidOutArea := (orientation decoratedEnd: endElement)
250
+ - (orientation decoratedStart: startElement).
251
+
252
+ laidOutRange := ((self childPositionOf: startElement)
253
+ - (self childPositionOf: endElement)) abs + 1 .
254
+
255
+ ^ (laidOutArea / laidOutRange * self state itemCount) asFloat
208
256
]
209
257
210
258
{ #category : #scrolling }
@@ -246,20 +294,6 @@ BlInfiniteLinearLayout >> computeVerticalScrollRange [
246
294
^ self computeScrollRange
247
295
]
248
296
249
- { #category : #' private - scrolling' }
250
- BlInfiniteLinearLayout >> createScrollbarHelper [
251
- < return: #BlInfiniteScrollbarHelper >
252
-
253
- ^ BlInfiniteScrollbarHelper new
254
- state: infiniteElement state;
255
- orientation: orientation;
256
- startElement: (self findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not acceptPartiallyVisible: true );
257
- endElement: (self findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not acceptPartiallyVisible: true );
258
- layout: self ;
259
- smoothScrollbarEnabled: smoothScrollbarEnabled;
260
- isReversedLayout: shouldReverseLayout
261
- ]
262
-
263
297
{ #category : #initialization }
264
298
BlInfiniteLinearLayout >> defaultAnchorInfo [
265
299
^ BlInfiniteLinearLayoutAnchorInfo new
0 commit comments