javascript - 如何永久设置高亮持续时间

标签 javascript extjs highlight extjs6

我想永久设置 Ext.get(el).highlight() 函数的持续时间。这可能不使用 cls 吗?我已经尝试为持续时间配置赋予无穷大。但是我这样做会收到很多错误。

最佳答案

您需要重写函数highlight。有恒定的 1000ms。

Ext.dom.Element.override({
    highlight: function(color, options) {
            var me = this,
                dom = me.dom,
                from = {},
                animFly = new Ext.dom.Fly(),
                restore, to, attr, lns, event, fn;

            options = options || {};
            lns = options.listeners || {};
            attr = options.attr || 'backgroundColor';
            from[attr] = color || 'ffff9c';

            if (!options.to) {
                to = {};
                to[attr] = options.endColor || me.getColor(attr, 'ffffff', '');
            }
            else {
                to = options.to;
            }

            // Don't apply directly on lns, since we reference it in our own callbacks below
            options.listeners = Ext.apply(Ext.apply({}, lns), {
                beforeanimate: function() {
                    // Reattach to the DOM in case the caller animated a Fly
                    // in which case the dom reference will have changed by now.
                    animFly.attach(dom);

                    restore = dom.style[attr];
                    animFly.clearOpacity();
                    animFly.show();

                    event = lns.beforeanimate;

                    if (event) {
                        fn = event.fn || event;

                        return fn.apply(event.scope || lns.scope || WIN, arguments);
                    }
                },
                afteranimate: function() {
                    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({}, options, {
                duration: 10000, // here new duration ms
                easing: 'ease-in',
                from: from,
                to: to
            }));

            return me;
        }
});

或者您可以将配置附加到 highlight 方法,例如:

Ext.get(el).highlight("#ffff9c", {
    attr: "backgroundColor",
    endColor: "#ffffff",
    easing: 'easeIn',
    duration: 4000
});

关于javascript - 如何永久设置高亮持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58319417/

相关文章:

javascript - Javascript 中已定义对象的数组

javascript - ExtJS:在具有特定类的元素上放置一个 onclick 事件

javascript - 使用 ext js 4.1 在网格中突出显示一行

java - 删除 JComboBox 中的突出显示

emacs - 在 Emacs 中高亮标记环位置

javascript - 当用户特别选择一项时,JQUERY 使复选框项禁用

javascript - 如何在 NextJS/_document.js 文件中获取路径名

javascript - history.createBrowserHistory 不是函数 - React js

extjs - 如何设定焦点?

javascript - jQuery "blinking highlight"对 div 的影响?