你可以有一個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