Skip to content

Commit

Permalink
Remove unnecessary help class
Browse files Browse the repository at this point in the history
  • Loading branch information
refactoringdr committed Aug 29, 2024
1 parent 9ff4310 commit bbfea57
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 254 deletions.
92 changes: 63 additions & 29 deletions src/BlocPac-Infinite-Layouts/BlInfiniteLinearLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -180,31 +180,79 @@ BlInfiniteLinearLayout >> computeHorizontalScrollRange [
{ #category : #'private - scrolling' }
BlInfiniteLinearLayout >> computeScrollExtent [
<return: #Number>

self hasChildren
ifFalse: [ ^ 0 ].

^ self createScrollbarHelper computeScrollExtent
| anExtent startElement endElement |
self hasChildren ifFalse: [ ^ 0 ].

startElement := self
findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.
endElement := self
findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.

anExtent := (orientation decoratedEnd: endElement)
- (orientation decoratedStart: startElement).

^ orientation totalSpace min: anExtent
]

{ #category : #'private - scrolling' }
BlInfiniteLinearLayout >> computeScrollOffset [
<return: #Number>

self hasChildren
ifFalse: [ ^ 0 ].

^ self createScrollbarHelper computeScrollOffset
| startPosition endPosition minPosition maxPosition itemsBefore laidOutArea itemRange avgSizePerRow startElement endElement |
self hasChildren ifFalse: [ ^ 0 ].

startElement := self
findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.
endElement := self
findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.

startPosition := self childPositionOf: startElement.
endPosition := self childPositionOf: endElement.

minPosition := startPosition min: endPosition.
maxPosition := startPosition max: endPosition.

itemsBefore := 0
max: (shouldReverseLayout
ifTrue: [ self state itemCount - maxPosition - 1 ]
ifFalse: [ minPosition - 1 ]).

smoothScrollbarEnabled ifFalse: [ ^ itemsBefore ].

laidOutArea := ((orientation decoratedEnd: endElement)
- (orientation decoratedStart: startElement)) abs.
itemRange := (startPosition - endPosition) abs + 1.
avgSizePerRow := (laidOutArea / itemRange) asFloat.

^ itemsBefore * avgSizePerRow
+ (orientation startWithPadding - (orientation decoratedStart: startElement))
]

{ #category : #'private - scrolling' }
BlInfiniteLinearLayout >> computeScrollRange [
<return: #Number>

self hasChildren
ifFalse: [ ^ 0 ].

^ self createScrollbarHelper computeScrollRange
| laidOutArea startElement endElement laidOutRange |
self hasChildren ifFalse: [ ^ 0 ].

smoothScrollbarEnabled ifFalse: [ ^ self state itemCount ].

startElement := self
findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.
endElement := self
findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not
acceptPartiallyVisible: true.

laidOutArea := (orientation decoratedEnd: endElement)
- (orientation decoratedStart: startElement).

laidOutRange := ((self childPositionOf: startElement)
- (self childPositionOf: endElement)) abs + 1.

^ (laidOutArea / laidOutRange * self state itemCount) asFloat
]

{ #category : #scrolling }
Expand Down Expand Up @@ -246,20 +294,6 @@ BlInfiniteLinearLayout >> computeVerticalScrollRange [
^ self computeScrollRange
]

{ #category : #'private - scrolling' }
BlInfiniteLinearLayout >> createScrollbarHelper [
<return: #BlInfiniteScrollbarHelper>

^ BlInfiniteScrollbarHelper new
state: infiniteElement state;
orientation: orientation;
startElement: (self findFirstVisibleChildClosestToStartCompletelyVisible: smoothScrollbarEnabled not acceptPartiallyVisible: true);
endElement: (self findFirstVisibleChildClosestToEndCompletelyVisible: smoothScrollbarEnabled not acceptPartiallyVisible: true);
layout: self;
smoothScrollbarEnabled: smoothScrollbarEnabled;
isReversedLayout: shouldReverseLayout
]

{ #category : #initialization }
BlInfiniteLinearLayout >> defaultAnchorInfo [
^ BlInfiniteLinearLayoutAnchorInfo new
Expand Down
5 changes: 0 additions & 5 deletions src/BlocPac-Infinite/BlInfiniteElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1572,11 +1572,6 @@ BlInfiniteElement >> predictiveItemAnimationsEnabled [
and: [ layout supportsPredictiveItemAnimations ]
]

{ #category : #'accessing - properties' }
BlInfiniteElement >> prefetchingAllowed [
^ false
]

{ #category : #'private - commands' }
BlInfiniteElement >> processDataSourceCommandsAndSetAnimationFlags [
"Consumes data source commands and calculates which type of animations we want to run.
Expand Down
16 changes: 0 additions & 16 deletions src/BlocPac-Infinite/BlInfiniteScrollFlinger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ BlInfiniteScrollFlinger class >> on: anInfiniteElement [
yourself
]

{ #category : #hooks }
BlInfiniteScrollFlinger >> onFinished [
self scrollable prefetchingAllowed
ifTrue: [ self shouldBeImplemented ]
]

{ #category : #hooks }
BlInfiniteScrollFlinger >> onInitialized [
self scrollable eatRequestLayout.
Expand All @@ -33,17 +27,7 @@ BlInfiniteScrollFlinger >> onLayoutScrolled [
self scrollable resumeRequestLayout: false
]

{ #category : #hooks }
BlInfiniteScrollFlinger >> onNotFinished [
self scrollable prefetchingAllowed
ifTrue: [ self shouldBeImplemented ]
]

{ #category : #hooks }
BlInfiniteScrollFlinger >> onPrepareToRun [
self scrollable consumePendingDataSourceCommands
]

{ #category : #hooks }
BlInfiniteScrollFlinger >> onSmoothScrolled [
]
169 changes: 0 additions & 169 deletions src/BlocPac-Infinite/BlInfiniteScrollbarHelper.class.st

This file was deleted.

Loading

0 comments on commit bbfea57

Please sign in to comment.