Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
fix how centers are calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed Jun 5, 2013
1 parent 4379a5f commit d2deccd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
8 changes: 4 additions & 4 deletions js/hopscotch-0.1.js
Expand Up @@ -618,7 +618,7 @@
else if (step.placement === 'top' || step.placement === 'bottom') {
arrowEl.style.top = '';
if (arrowOffset === 'center') {
arrowEl.style.left = bubbleWidth/2 - this.opt.arrowWidth/2 + 'px';
arrowEl.style.left = bubbleWidth/2 + bubblePadding - arrowEl.getBoundingClientRect().width/2 + 'px';
}
else {
// Numeric pixel value
Expand All @@ -629,7 +629,7 @@
arrowEl.style.left = '';
if (arrowOffset === 'center') {
bubbleHeight = bubbleHeight || el.offsetHeight;
arrowEl.style.top = bubbleHeight/2 - this.opt.arrowWidth/2 + 'px';
arrowEl.style.top = bubbleHeight/2 + bubblePadding - arrowEl.getBoundingClientRect().height/2 + 'px';
}
else {
// Numeric pixel value
Expand All @@ -639,15 +639,15 @@

// HORIZONTAL OFFSET
if (step.xOffset === 'center') {
left = (boundingRect.left + boundingRect.width/2) - (bubbleWidth/2);
left = (boundingRect.left + boundingRect.width/2) - (bubbleWidth/2) - bubblePadding;
}
else {
left += utils.getPixelValue(step.xOffset);
}
// VERTICAL OFFSET
if (step.yOffset === 'center') {
bubbleHeight = bubbleHeight || el.offsetHeight;
top = (boundingRect.top + boundingRect.height/2) - (bubbleHeight/2);
top = (boundingRect.top + boundingRect.height/2) - (bubbleHeight/2) - bubblePadding;
}
else {
top += utils.getPixelValue(step.yOffset);
Expand Down

0 comments on commit d2deccd

Please sign in to comment.