Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Fixed problem with canvas tips when using border property
Browse files Browse the repository at this point in the history
Previously the canvas drawing method was translating the canvas origin, but not restoring it.
This was causing the tip to be redrawn later on outside the canvas, as it was being translated in
relation to the current canvas origin.
  • Loading branch information
Craga89 committed Aug 10, 2010
1 parent 7bc9a2c commit 47874e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tips.js
Expand Up @@ -313,8 +313,10 @@ function Tip(qTip, command)
switch(method)
{
case 'canvas':
// Grab canvas context
// Grab canvas context and clear it
context = inner.get(0).getContext('2d');
context.clearRect(0,0,3000,3000);
context.restore();

// Determine tip coordinates based on dimensions
if(border) {
Expand All @@ -325,6 +327,9 @@ function Tip(qTip, command)
context.lineWidth = border + 1;
context.lineJoin = 'miter';
context.miterLimit = 100;

// Save and translate canvas origin
context.save();
context.translate(
mimic.x === 'left' ? 0 : mimic.x === 'right' ? -width : -width / 2,
mimic.y === 'top' ? 0 : mimic.y === 'bottom' ? -height : -height / 2
Expand All @@ -337,7 +342,6 @@ function Tip(qTip, command)
// Setup canvas properties
context.fillStyle = color.fill;
context.miterLimit = 0;
context.clearRect(0,0,3000,3000);

// Draw the canvas tip (Delayed til after DOM creation)
for(i; i < 2; i++) {
Expand Down

0 comments on commit 47874e9

Please sign in to comment.