Latency issue with Primefaces overlayPanel - loads to lazy

后端 未结 4 1893
天涯浪人
天涯浪人 2021-01-04 22:51

I am using Primefaces 3.2 with jsf 2 and glassfish 3.1.2.

I have a p:dataTable of users containing avatars of the user. Whenever the user moves the mouse over the av

4条回答
  •  [愿得一人]
    2021-01-04 23:32

    As my first answer is already very long and contains valid information, I decided to open a new answer presenting my final approach.

    Im now using Primefaces inheritance pattern making the code alot cleaner. Also I noticed that replacing/overwriting the whole bindEvents function isnt necessary, as we can remove the old event handlers. Finally this code fixs the latest issue experienced: A hide event before ajax arrival.

    PrimeFaces.widget.OverlayPanel = PrimeFaces.widget.OverlayPanel
            .extend({
    
                bindEvents : function() {
                    this._super();
    
                    var showEvent = this.cfg.showEvent + '.ui-overlay', hideEvent = this.cfg.hideEvent
                            + '.ui-overlay';
    
                    $(document).off(showEvent + ' ' + hideEvent, this.targetId).on(
                            showEvent, this.targetId, this, function(e) {
                                var _self = e.data;
    
                                clearTimeout(_self.timer);
                                _self.timer = setTimeout(function() {
                                    _self.hidden = false;
                                    _self.show();
                                }, 300);
                            }).on(hideEvent, this.targetId, this, function(e) {
                        var _self = e.data;
    
                        clearTimeout(_self.timer);
                        _self.hidden = true;
                        _self.hide();
    
                    });
                },
    
                _show : function() {
                    if (!this.cfg.dynamic || !this.hidden) {
                        this._super();
                    }
                }
    
            });
    

    Im sorry for the poor formatting: Eclipses fault ;)

提交回复
热议问题