我有 3 个 listItems,当我单击其中一个时,我希望绿色条从右到左进行动画处理。但它的行为不正常。当您单击时没有任何反应,当您第二次单击时(可选地在另一行上),事情就会变得很时髦。对此有适当的解决方案吗?
http://jsfiddle.net/joopmicroop/6GJs4/
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);