From be1759aac8d6bebfc46035ab327633387b53e0c1 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Wed, 20 Jan 2016 23:26:22 -0500 Subject: [PATCH] Document behavior of scroll-change action in README --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 4ecebb6e..7941adf8 100755 --- a/README.md +++ b/README.md @@ -77,6 +77,37 @@ Once the collection has been rendered, `estimated-width` and `estimated-height` You must specify the `height`, `width` and `cell-layout` parameters because *EmberCollection* will try to fill visible area with items. +### Actions + +#### scroll-change + +If you do not provide a `scroll-change` action name or closure action, scrolling will work normally. + +If you *do* specify `scroll-change`, ember-collection assumes that you want to handle the scroll-change action in a true data down, actions up manner. For this reason, ember-collection will not set `scroll-left` and `scroll-right` itself, but rather rely on you to update those properties based on action handling as you see fit. + +An example of specifying an action and keeping scrolling working normally looks like this: + +```hbs +{{#ember-collection items=model cell-layout=(fixed-grid-layout itemWidth itemHeight) + scroll-left=scrollLeft scroll-top=scrollTop scroll-change=(action "scrollChange") + as |item index| }} +
{{item.name}}
+{{/ember-collection}} +``` + +```js +export default Ember.Controller.extend({ + scrollLeft: 0, + scrollTop: 0, + actions: { + scrollChange(scrollLeft, scrollTop) { + this.set('scrollLeft', scrollLeft); + this.set('scrollTop', scrollTop); + } + } +}); +``` + ## Build It 1. `git clone https://github.com/emberjs/ember-collection.git`