我们正在构建一个 ember-pagination帮助程序员对数组集合中的元素进行分页的库。到目前为止,我们设法放置了所有内容,使分页有效,还添加了提前输入以帮助搜索,但我们想知道当我们在 Ember 中应用某些过滤器或进行分页时是否有一种方法可以使元素动画化。 js
最佳答案
当然。可能最简单的方法是从一些动画库创建一个 block 组件,如 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}}
关于jquery - 分页动画 Ember 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25584345/