2014-08-30 54 views
1

我们正在构建一个ember-pagination库,它可以帮助程序员处理数组集合中项目的分页。到目前为止,我们设法将所有内容放在一起,使分页工作,并添加了一个帮助搜索的类型,但我们想知道是否有一种方法可以在我们应用某个过滤器或在Ember中进行分页时为项目设置动画。 js分页动画灰烬集合

回答

1

当然。可能最简单的方法是从一些动画库(如velocity)创建一个块组件,并将其包装在分页项目中。让组件带一个表示单独分页项目的jQuery选择器,然后用选择器实例化动画插件。您可以执行.observes('content')并在内容更改时让组件重新渲染。这里有一个简单的例子:

App.MyAnimationComponent = Ember.Component.extend({ 

    didInsertElement: function() { 
     var selector = this.get('selector'); 
     this.$(selector).animateLibrary({ options: 'foo' }); 
    }, 

    fireOnNewContent: function() { 
     this.rerender(); 
    }.observes('content') 

}); 

而且你会使用像这样:

{{#my-animation selector='.item'}} 
    {{#each items}} 
     <div class="item">{{foo}}</div> 
    {{/each}} 
{{/my-animation}}