From 3c8365538a14577f6cf4a5c828818368db16d424 Mon Sep 17 00:00:00 2001 From: Anh Nhan Nguyen Date: Sat, 6 Apr 2013 12:57:44 -0700 Subject: [PATCH] Fix flickering hovercards Summary: Refs T1048, T2902 - This //should// fix flickering hovercards. Probably does not fix displaced hovercards, though could (because of the flickering doing something bad to rendering). I'm bad with JS D: Test Plan: Tried out plenty of reload & hover combos. No flickering anymore. Never again. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1048 Differential Revision: https://secure.phabricator.com/D5607 --- src/__celerity_resource_map__.php | 2 +- webroot/rsrc/js/application/core/Hovercard.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 83ab542b75..c172f5e191 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -3043,7 +3043,7 @@ celerity_register_resource_map(array( ), 'phabricator-hovercard' => array( - 'uri' => '/res/345f3fca/rsrc/js/application/core/Hovercard.js', + 'uri' => '/res/80f2fdb1/rsrc/js/application/core/Hovercard.js', 'type' => 'js', 'requires' => array( diff --git a/webroot/rsrc/js/application/core/Hovercard.js b/webroot/rsrc/js/application/core/Hovercard.js index 86dc8d2652..2bb018da01 100644 --- a/webroot/rsrc/js/application/core/Hovercard.js +++ b/webroot/rsrc/js/application/core/Hovercard.js @@ -48,9 +48,15 @@ JX.install('Hovercard', { _drawCard : function(phid) { var self = JX.Hovercard; + // Already displaying + if (self.getCard() && phid == self._visiblePHID) { + return; + } + // Not the current requested card if (phid != self._visiblePHID) { return; } + // Not loaded if (!(phid in self._cards)) { return; } @@ -121,8 +127,10 @@ JX.install('Hovercard', { for (var phid in r.cards) { self._cards[phid] = r.cards[phid]; - if (self.getCard()) { - self.hide(); + // Don't draw if the user is faster than the browser + // Only draw if the user is still requesting the original card + if (self.getCard() && phid != self._visiblePHID) { + continue; } self._drawCard(phid);