Skip to content

Commit 843c76a

Browse files
committed
Update CollectionScrollView to native scrolling with vertical-collection
1 parent 8964314 commit 843c76a

File tree

11 files changed

+490
-437
lines changed

11 files changed

+490
-437
lines changed

addon/components/collection-scroll-view/collection-items/index.hbs

Lines changed: 0 additions & 1 deletion
This file was deleted.

addon/components/collection-scroll-view/collection-items/index.js

Lines changed: 0 additions & 205 deletions
This file was deleted.
Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,44 @@
1-
<ScrollView
2-
class="CollectionScrollView"
3-
@contentHeight={{this.scrollHeight}}
4-
@scrollTopOffset={{@scrollTopOffset}}
5-
@initialScrollTop={{@initialScrollTop}}
6-
@key={{@key}}
7-
@auxiliaryComponent={{if @auxiliaryComponent
8-
(component @auxiliaryComponent
9-
cellLayout=this.cellLayout
10-
items=@items
11-
clientSize=this.collectionClientSize
12-
scrollTop=this.collectionScrollTop
13-
verticalOffset=this.visibleHeaderHeight
14-
)
15-
}}
16-
@clientSizeChange={{this.clientSizeChange}}
17-
@scrollChange={{this.scrollChange}}
18-
@scrolledToTopChange={{this.onScrolledToTopChange}}
19-
{{create-ref 'element'}}
20-
...attributes
21-
as |scrollViewApi|
1+
<div
2+
class="CollectionScrollView-scrollContainer"
3+
data-test-scroll-container
4+
{{this.registerScrollElement}}
5+
{{on "scroll" this.handleScroll}}
6+
{{on-resize this.handleResize}}
227
>
23-
24-
{{#if (has-block 'header')}}
25-
<div {{on-resize (fn this.updateHeaderDimensions scrollViewApi)}}>
26-
{{yield to="header"}}
27-
</div>
28-
{{/if}}
29-
30-
{{#if (not (and (has-block 'header') (is-empty this.headerDimensions)))}}
31-
<div data-test-collection-items-container style={{html-safe (concat "position:relative;height:" this.contentSize.height "px;width:" this.contentSize.width "px")}}>
32-
<CollectionScrollView::CollectionItems
33-
@clientSize={{this.collectionClientSize}}
34-
@scrollTop={{this.collectionScrollTop}}
35-
@estimatedSize={{hash width=@estimated-width height=@estimated-height}}
36-
@items={{@items}}
37-
@buffer={{@buffer}}
38-
@cellLayout={{this.cellLayout}}
39-
@onContentSizeUpdated={{this.updateContentSizeAfterRender}}
40-
as |cells|
41-
>
42-
{{~#each cells as |cell|~}}
43-
<div style={{html-safe cell.style}} data-collection-scroll-view-cell-container-id={{cell.containerId}}>{{yield cell.item cell.index scrollViewApi to="row"}}</div>
44-
{{~/each~}}
45-
</CollectionScrollView::CollectionItems>
46-
</div>
8+
{{#if @auxiliaryComponent}}
9+
{{component @auxiliaryComponent
10+
cellLayout=@cellLayout
11+
items=@items
12+
clientSize=this.collectionClientSize
13+
scrollTop=this.scrollTop
14+
verticalOffset=this.visibleHeaderHeight
15+
}}
4716
{{/if}}
17+
<VerticalCollection
18+
@bufferSize={{@buffer}}
19+
@estimateHeight={{@estimateItemHeight}}
20+
@firstVisibleChanged={{this.firstVisibleChanged}}
21+
@items={{@items}}
22+
@key={{or @itemKey "id"}}
23+
@registerAPI={{this.registerAPI}}
24+
@renderAll={{false}}
25+
@staticHeight={{@staticHeight}}
26+
@width={{@width}}
27+
as |item index|
28+
>
29+
{{yield item index to="row"}}
30+
</VerticalCollection>
31+
{{emitter-action
32+
emitter=this.windowRef
33+
eventName="requestScrollToTop"
34+
action=this.scrollToTopIfInViewport
35+
}}
4836

4937
{{#if @revealService}}
5038
{{emitter-action
5139
emitter=@revealService
5240
eventName="revealItemById"
53-
action=(fn this.scrollToItem scrollViewApi)
41+
action=this.scrollToItem
5442
}}
5543
{{/if}}
56-
</ScrollView>
44+
</div>

0 commit comments

Comments
 (0)