fixed annoying tooltip flicker bug. popcorn-port
authorhamidouk
Mon, 19 Dec 2011 12:08:50 +0100
branchpopcorn-port
changeset 478 1422ba0fc333
parent 477 1e51d638e7ea
child 479 24308670f1bb
fixed annoying tooltip flicker bug.
src/js/widgets/polemicWidget.js
src/js/widgets/tooltipWidget.js
--- a/src/js/widgets/polemicWidget.js	Mon Dec 19 10:53:34 2011 +0100
+++ b/src/js/widgets/polemicWidget.js	Mon Dec 19 12:08:50 2011 +0100
@@ -300,12 +300,10 @@
                   });
                   */
                   
-                  IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {
+                  IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {                        
                         // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
                         self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.clientX - 106, event.clientY - 160);
                         element.displayed = true;
-                  }}(e)).mouseleave(function(element) { return function () {                          
-                          self.TooltipWidget.hide.call(self.TooltipWidget);
                   }}(e)).mousedown(function () {
                     self._Popcorn.currentTime(this.time/1000);
                     self._Popcorn.trigger("IriSP.PolemicTweet.click", this.id); 
@@ -351,6 +349,7 @@
       this.sliderTip.toFront();
     }
     
+    this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
     this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
 }
 
--- a/src/js/widgets/tooltipWidget.js	Mon Dec 19 10:53:34 2011 +0100
+++ b/src/js/widgets/tooltipWidget.js	Mon Dec 19 12:08:50 2011 +0100
@@ -22,29 +22,21 @@
 };
 
 IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
-  if (this._shown === true || this._displayedText == text)
+
+  if (this._displayedText == text)
     return;
-    
-  // cancel the timeout for the previously displayed element.
-  if (this._hideTimeout != -1) {
-    window.clearTimeout(this._hideTimeout);
-    this._hideTimeout = -1;
-    console.log(text === this._displayedText);
-  }
-  debugger;
   
   this.selector.find(".tipcolor").css("background-color", color);
   this._displayedText = text;
 	this.selector.find(".tiptext").text(text);
   //this.selector.find(".tip").css("left", x).css("top", y);  
-  this.selector.find(".tip").css("left", x).css("top", "-160px");
+  this.selector.find(".tip").css("left", x).css("top", "-180px");
   this.selector.find(".tip").show();
   this._shown = true;
 };
 
-IriSP.TooltipWidget.prototype.hide = function() {  
-  this._hideTimeout = window.setTimeout(IriSP.wrap(this, function() {                                                  
-                                                  this.selector.find(".tip").hide();
-                                                  this._shown = false; }), 1000);
-  
+IriSP.TooltipWidget.prototype.hide = function() {                                                   
+  console.log("hide");  
+  this.selector.find(".tip").hide();
+  this._shown = false;  
 };