Skip to content

Commit bbfea57

Browse files
committed
Remove unnecessary help class
1 parent 9ff4310 commit bbfea57

File tree

5 files changed

+77
-254
lines changed

5 files changed

+77
-254
lines changed

src/BlocPac-Infinite-Layouts/BlInfiniteLinearLayout.class.st

+63-29
Original file line numberDiff line numberDiff line change
@@ -180,31 +180,79 @@ BlInfiniteLinearLayout >> computeHorizontalScrollRange [
180180
{ #category : #'private - scrolling' }
181181
BlInfiniteLinearLayout >> computeScrollExtent [
182182
<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
188197
]
189198

190199
{ #category : #'private - scrolling' }
191200
BlInfiniteLinearLayout >> computeScrollOffset [
192201
<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))
198232
]
199233

200234
{ #category : #'private - scrolling' }
201235
BlInfiniteLinearLayout >> computeScrollRange [
202236
<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
208256
]
209257

210258
{ #category : #scrolling }
@@ -246,20 +294,6 @@ BlInfiniteLinearLayout >> computeVerticalScrollRange [
246294
^ self computeScrollRange
247295
]
248296

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-
263297
{ #category : #initialization }
264298
BlInfiniteLinearLayout >> defaultAnchorInfo [
265299
^ BlInfiniteLinearLayoutAnchorInfo new

src/BlocPac-Infinite/BlInfiniteElement.class.st

-5
Original file line numberDiff line numberDiff line change
@@ -1572,11 +1572,6 @@ BlInfiniteElement >> predictiveItemAnimationsEnabled [
15721572
and: [ layout supportsPredictiveItemAnimations ]
15731573
]
15741574

1575-
{ #category : #'accessing - properties' }
1576-
BlInfiniteElement >> prefetchingAllowed [
1577-
^ false
1578-
]
1579-
15801575
{ #category : #'private - commands' }
15811576
BlInfiniteElement >> processDataSourceCommandsAndSetAnimationFlags [
15821577
"Consumes data source commands and calculates which type of animations we want to run.

src/BlocPac-Infinite/BlInfiniteScrollFlinger.class.st

-16
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ BlInfiniteScrollFlinger class >> on: anInfiniteElement [
1414
yourself
1515
]
1616

17-
{ #category : #hooks }
18-
BlInfiniteScrollFlinger >> onFinished [
19-
self scrollable prefetchingAllowed
20-
ifTrue: [ self shouldBeImplemented ]
21-
]
22-
2317
{ #category : #hooks }
2418
BlInfiniteScrollFlinger >> onInitialized [
2519
self scrollable eatRequestLayout.
@@ -33,17 +27,7 @@ BlInfiniteScrollFlinger >> onLayoutScrolled [
3327
self scrollable resumeRequestLayout: false
3428
]
3529

36-
{ #category : #hooks }
37-
BlInfiniteScrollFlinger >> onNotFinished [
38-
self scrollable prefetchingAllowed
39-
ifTrue: [ self shouldBeImplemented ]
40-
]
41-
4230
{ #category : #hooks }
4331
BlInfiniteScrollFlinger >> onPrepareToRun [
4432
self scrollable consumePendingDataSourceCommands
4533
]
46-
47-
{ #category : #hooks }
48-
BlInfiniteScrollFlinger >> onSmoothScrolled [
49-
]

src/BlocPac-Infinite/BlInfiniteScrollbarHelper.class.st

-169
This file was deleted.

0 commit comments

Comments
 (0)