Thanks @Ryan for the answer, this is exactly what I was looking for. I went a bit further with your code and gave more functionality.
I added 2 new options to tipsy so that it does the following:
- On
sw
/nw
, you can use edgeAlignWest: 'right'
or edgeAlignWest: 'center'
- On
se
/ne
, you can use edgeAlignEast: 'left'
or edgeAlignEast: 'center'
The new code to do this is
// line 61, tipsy version 1.0.0a
if (gravity.length == 2) {
if (gravity.charAt(1) == 'e') {
tp.left = (this.options.edgeAlignEast == 'right') ? (pos.left + pos.width - actualWidth + 15) : (pos.left + pos.width / 2 - actualWidth + 15);
}else if (gravity.charAt(1) == 'w') {
tp.left = (this.options.edgeAlignWest == 'left') ? (pos.left - 5) : (pos.left + pos.width / 2 - 15);
} else {
tp.left = pos.left + pos.width / 2 - actualWidth + 15;
}
}
//...
// line 191, tipsy version 1.0.0a
$.fn.tipsy.defaults = {
edgeAlignEast: 'center', // <-- new option, default to 'center', you can also use 'right'
edgeAlignWest: 'center', // <-- new option, default to 'center', you can also use 'left'
className: null,
delayIn: 0,
delayOut: 0,
fade: false,
fallback: '',
gravity: 'n',
html: false,
live: false,
offset: 0,
opacity: 0.8,
title: 'title',
trigger: 'hover'
};