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

Commit

Permalink
add center option for arrowOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed Jun 5, 2013
1 parent a6f0962 commit be5f972
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 35 deletions.
27 changes: 23 additions & 4 deletions js/hopscotch-0.1.js
Expand Up @@ -568,11 +568,11 @@
boundingRect,
top,
left,
arrowOffset,
bubbleBorder = 6,
targetEl = utils.getStepTarget(step),
el = this.element,
arrowEl = this.arrowEl,
arrowOffset = utils.getPixelValue(step.arrowOffset);
arrowEl = this.arrowEl;

bubbleWidth = utils.getPixelValue(step.width) || this.opt.bubbleWidth;
bubblePadding = utils.valOrDefault(step.padding, this.opt.bubblePadding);
Expand Down Expand Up @@ -605,17 +605,36 @@
}

// SET (OR RESET) ARROW OFFSETS
if (step.arrowOffset !== 'center') {
arrowOffset = utils.getPixelValue(step.arrowOffset);
}
else {
arrowOffset = step.arrowOffset;
}
if (!arrowOffset) {
arrowEl.style.top = '';
arrowEl.style.left = '';
}
else if (step.placement === 'top' || step.placement === 'bottom') {
arrowEl.style.top = '';
arrowEl.style.left = arrowOffset + 'px';
if (arrowOffset === 'center') {
arrowEl.style.left = bubbleWidth/2 - this.opt.arrowWidth/2 + 'px';
}
else {
// Numeric pixel value
arrowEl.style.left = arrowOffset + 'px';
}
}
else if (step.placement === 'left' || step.placement === 'right') {
arrowEl.style.left = '';
arrowEl.style.top = arrowOffset + 'px';
if (arrowOffset === 'center') {
bubbleHeight = bubbleHeight || el.offsetHeight;
arrowEl.style.top = bubbleHeight/2 - this.opt.arrowWidth/2 + 'px';
}
else {
// Numeric pixel value
arrowEl.style.top = arrowOffset + 'px';
}
}

// HORIZONTAL OFFSET
Expand Down

0 comments on commit be5f972

Please sign in to comment.