From e85a190ea9b3ebb95254bde578eab88d11da08b2 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Wed, 12 Dec 2012 12:45:35 -0500 Subject: [PATCH 1/2] Removed unnecessary canvas skipPositioning flag. The primary canvas uses position: absolute while the overlay canvas does not. This can cause the two to get out of alignment in rare cases when floating elements are placed near the plot placeholder. There doesn't appear to be any reason why the overlay can't also be absolutely-positioned, so I've just removed the flag entirely. --- jquery.flot.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index b82a2ad..6d5d3a7 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -738,15 +738,13 @@ Licensed under the MIT license. return devicePixelRatio / backingStoreRatio; } - function makeCanvas(skipPositioning, cls) { + function makeCanvas(cls) { var c = document.createElement('canvas'); c.className = cls; - if (!skipPositioning) - $(c).css({ position: 'absolute', left: 0, top: 0 }); - - $(c).appendTo(placeholder); + $(c).css({ position: 'absolute', left: 0, top: 0 }) + .appendTo(placeholder); // If HTML5 Canvas isn't available, fall back to Excanvas @@ -842,8 +840,8 @@ Licensed under the MIT license. getCanvasDimensions(); - canvas = makeCanvas(true, "flot-base"); - overlay = makeCanvas(false, "flot-overlay"); // overlay canvas for interactive features + canvas = makeCanvas("flot-base"); + overlay = makeCanvas("flot-overlay"); // overlay canvas for interactive features reused = false; } From de86d017a0ea26edcc8db79d19a79f4a6e8c6dc9 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Wed, 12 Dec 2012 12:53:40 -0500 Subject: [PATCH 2/2] Updated news for the canvas alignment fix. --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index b47c8cb..90ad945 100644 --- a/NEWS.md +++ b/NEWS.md @@ -155,6 +155,9 @@ The base and overlay canvas are now using the CSS classes "flot-base" and - Prevented several local variables from becoming global. (patch by aaa707) + - Ensure that the overlay and primary canvases remain aligned. (issue #670, + pull request #901) + ## Flot 0.7 ## ### API changes ###