Skip to content

Instantly share code, notes, and snippets.

@syllog1sm
Created September 30, 2013 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syllog1sm/6759165 to your computer and use it in GitHub Desktop.
Save syllog1sm/6759165 to your computer and use it in GitHub Desktop.
var placement = (steps[i].options && steps[i].options.placement) ? steps[i].options.placement : options.placement;
var css = {};
if (placement === 'right') {
css.top = top + (height / 3) + "px";
css.left = left + element.outerWidth() + margin;
} else if (placement === 'left') {
css.top = top + (height / 3) + "px";
css.left = (left - element.outerWidth()) - margin;
} else if (placement === 'bottom') {
css.top = (height + top + margin + 10) + "px";
if ((left + bubble.outerWidth()) > $(document).width()) {
$(".guideBubble-arrow", bubble).css({"right": "10px"});
css.left = left + (element.outerWidth() - bubble.outerWidth()) + margin;
} else {
$(".guideBubble-arrow", bubble).css({"right": "auto"});
css.left = left;
}
} else if (placement === 'top') {
css.top = (((top - bubble.outerHeight()) - margin) - 20) + "px";
if ((left + bubble.outerWidth()) > $(document).width()) {
$(".guideBubble-arrow", bubble).css({"right": "10px"});
css.left = left + element.outerWidth() - bubble.outerWidth() + margin;
} else {
$(".guideBubble-arrow", bubble).css({"right": "auto"});
css.left = left + margin;
}
}
$('.guideBubble-arrow').attr('data-placement', placement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment