lorenzos/FloatingTips — Issue #10: Suggestion: offset option callback-able
Author: afoeder
Created: 2011-12-30 16:11:30+00:00
State: open

Hi Lorenzo,

In my case it was useful to have the offset-option a callback because I wanted to float-tip a progress-bar-percentage; so I had to calculate the offset dependant of the progress.

so right after the line
var tipSz = tip.getSize(), trgC = elem.getCoordinates(body);

I added
var offsetOption = ( 'function' === typeOf(o.offset) ? Object.merge({x:0, y:0}, o.offset(elem)) : o.offset );

and replaced the following line with

var pos = { x: trgC.left + offsetOption.x, y: trgC.top + offsetOption.y };

(sorry I'm too lazy to build a pull request)

This checks of the given offset option is a function; if so, it invokes it and merges the result with x:0 and y:0 (the callback function *has* to return an object with x and/or y).
So basically the functionality keeps the same with the exception that, in case of a function is given, it is invoked.

Thanks and best!
-adrian