首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >enyo为listItem设置动画

enyo为listItem设置动画
EN

Stack Overflow用户
提问于 2013-07-04 19:44:43
回答 1查看 297关注 0票数 0

我有一个3的listItems,当我单击其中一个时,我希望绿色条从右到左显示动画。但它的行为并不正常。当你点击的时候什么都没有发生,当你第二次点击(可选的在另一行)时,事情就变得时髦起来。对此有合适的解决方案吗?

http://jsfiddle.net/joopmicroop/6GJs4/

代码语言:javascript
复制
enyo.kind({
    name:'main',
    classes: "enyo-fit",
    components:[ 
        {name:'list', kind:'enyo.List', count:'3', onSetupItem:'itemSetup', components:[
            {name:'listItem', kind:'listItem', ontap:'itemTapped'},    
        ]}, 
    ],
    itemTapped:function(s,e){
        console.log('itemTapped',e.rowIndex);
        this.$.list.prepareRow(e.rowIndex);
        this.$.list.performOnRow(e.rowIndex, function(){ this.animate(); }, this.$.listItem);
        this.$.list.lockRow();
        this.$.list.renderRow(e.rowIndex);
    },
    itemSetup:function(s,e){ this.$.listItem.setText('item'+e.index); }
});

enyo.kind({
    name:'listItem',
    classes:'listItem',
    published:{text:''},
    create:function(){
        this.inherited(arguments);
        this.animator = new enyo.Animator({
            onStep:enyo.bind(this, function(animObj){
                this.$.backBar.applyStyle('width',animObj.value+'%');
            }),duration:1000
        });
    },
    components:[
        {name:'backBar', classes:'animBar'},
        {name:'itemContent', content:''},
    ],
    animate:function(){
        if(!this.animator.isAnimating()) this.animator.play({startValue:10, endValue:100});
    },
    textChanged:function(oldVal){ this.$.itemContent.setContent(this.text); },
});

(new main()).renderInto(document.body);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-05 01:39:30

这里遇到的最大问题是,在调用performOnRow()之后,该行不再有节点。不需要额外调用lockRow(),因为它是自动锁定的。如果希望这样做,则需要在准备好行之后使用不同的方法,或者需要缓存节点并直接在节点上操作。您可以使用一些CSS动画来完成此操作,因为您只需要足够长的时间来设置新值一次,然后让浏览器执行动画。

忘记添加:在呈现控件之前,不会实际创建节点。如果只想在节点存在后执行操作,请重载rendered()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17469449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档