Ryan Brodie Ryan Brodie - 5 months ago 12
jQuery Question

Align jQuery Tipsy To Left Edge Of Element

I'm using the jQuery Tipsy Plugin to create tool tips in my project. Tooltips are automatically centred to the element, as seen on the plugin pages demos, but I'd like it to align to the left of element, does anyone know a method to do this? The plugin automatically sets an absolute position of the tooltip when displayed, I've tried altering this function but have had no luck.

Update 1: I am well aware of the docs and the

gravity
option, I am looking to centre the tooltips arrow to the left edge of it's corresponding element.

Update 2: Here's a mock up of how I want the tooltip to be placed:
Left: Current, Right: Intended

Answer

Found the solution, I was editing the wrong function. It turn's out there was another function specially for 'NW/SW' gravities, updated JS:

            if (gravity.length == 2) {
                if (gravity.charAt(1) == 'w') {
                    tp.left = pos.left - 5;
                } else {
                    tp.left = pos.left + pos.width / 2 - actualWidth + 15;
                }
            }

I'm going to fork this on Git incase other's need this functionality.