ashb commented on a change in pull request #8269: [AIRFLOW-4357] Fix SVG 
tooltip positioning with custom scripting
URL: https://github.com/apache/airflow/pull/8269#discussion_r408007203
 
 

 ##########
 File path: airflow/www/templates/airflow/dags.html
 ##########
 @@ -554,5 +552,33 @@ <h2>DAGs</h2>
       $(".loading-task-stats").remove();
       $(".loading-dag-stats").remove();
     }
+
+    function showSvgTooltip(text, offsetTop, offsetLeft) {
+      var tip = $('#svg-tooltip');
+      tip.children('.tooltip-inner').text(text);
+      var centeringOffset = tip.width() / 2;
+      tip.css({
+        "display": "block",
+        "left": offsetLeft + 12.5 - centeringOffset + 'px',// 12.5 == half of 
circle width
 
 Review comment:
   Rather than hard-coding these offsets, would it be cleaner/less future error 
prone to instead pass in the result of `getBoundingClientRect`, i.e. this 
function beceomes:
   
   ```js
        function showSvgTooltip(text, elemClientRect) { 
   ```
   
   or 
   ```js
        function showSvgTooltip(text, elemTop, elemLeft, elemBottom, elemRight 
) { 
   ```
   
   (TLBR, instead of TLXY as IEs' don't have X and Y attributes according to 
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to