你可以有一个afteranimate监听器事件并设置backgroundColor。
field.getEl().highlight('#fbac3d', {
attr: "backgroundColor",
endColor: "#ffffff",
easing: 'easeIn',
duration: 4000,
listerners: {
afteranimate: function() {
// here you can set style attributes to your field
}
}
});
或者,如果要制作此功能Universe,则可以覆盖突出显示方法。
Ext.dom.Element.override({
highlight: function(color, o) {
var me = this,
dom = me.dom,
from = {},
restore, to, attr, lns, event, fn;
o = o || {};
lns = o.listeners || {};
attr = o.attr || 'backgroundColor';
from[attr] = color || 'ffff9c';
if (!o.to) {
to = {};
to[attr] = o.endColor || me.getColor(attr, 'ffffff', '');
}
else {
to = o.to;
}
// Don't apply directly on lns, since we reference it in our own callbacks below
o.listeners = Ext.apply(Ext.apply({}, lns), {
beforeanimate: function() {
restore = dom.style[attr];
var el = Ext.fly(dom, '_anim');
el.clearOpacity();
el.show();
event = lns.beforeanimate;
if (event) {
fn = event.fn || event;
return fn.apply(event.scope || lns.scope || WIN, arguments);
}
},
afteranimate: function() {
//Commented this , here it restores background color
//if (dom) {
// dom.style[attr] = restore;
//}
event = lns.afteranimate;
if (event) {
fn = event.fn || event;
fn.apply(event.scope || lns.scope || WIN, arguments);
}
}
});
me.animate(Ext.apply({}, o, {
duration: 1000,
easing: 'ease-in',
from: from,
to: to
}));
return me;
}
});
例小提琴:https://fiddle.sencha.com/#fiddle/11mo
'field'(或其子类,如'displayfield')不具有'setStyle'功能;所以给出错误。 – talha06
setFieldStyle怎么样? –
是的,这就是我现在所做的。如果你编辑你的文章,我想把它标记为正确的答案。感谢您的指导。 PS。 setFieldStyle函数接受一个由css-rule和value组成的参数。目前它有一个语法问题。 – talha06