diff --git a/Docs/Interface/Tips.md b/Docs/Interface/Tips.md index c6d50529..3f8d8224 100644 --- a/Docs/Interface/Tips.md +++ b/Docs/Interface/Tips.md @@ -33,7 +33,7 @@ Tips Method: constructor * The tooltip element inside the tooltip container above will have 'tip' as classname. * The title will have as classname: tip-title * The text will have as classname: tip-text -* offset - (*object*: defaults to {x: 16, y: 16}) The distance of your tooltip from the mouse. +* offset - (*object*: defaults to {x: 16, y: 16}) The distance of your tooltip from the mouse. Can also accept a function as an argument for each offset (will be bound to `this`) * fixed - (*boolean*: defaults to *false*) If set to true, the tooltip will not follow the mouse. * windowPadding - (*object*; defaults to {x: 0, y: 0}) Allows you to reduce or expand the virtual size of the window for tip positioning. The tips will not be allowed to approach the edge of the window on any side based on this offset. * id - (*string*: defaults to *null*) Add an `id` to the tooltip element, required for WAI-ARIA support. diff --git a/Source/Interface/Tips.js b/Source/Interface/Tips.js index dfd06b6d..e2ad44cb 100644 --- a/Source/Interface/Tips.js +++ b/Source/Interface/Tips.js @@ -223,13 +223,15 @@ this.Tips = new Class({ tip = {x: this.tip.offsetWidth, y: this.tip.offsetHeight}, props = {x: 'left', y: 'top'}, bounds = {y: false, x2: false, y2: false, x: false}, - obj = {}; + obj = {}, + offset; for (var z in props){ - obj[props[z]] = event.page[z] + this.options.offset[z]; + offset = this.options.offset[z].call ? this.options.offset[z].call(this) : this.options.offset[z]; + obj[props[z]] = event.page[z] + offset; if (obj[props[z]] < 0) bounds[z] = true; if ((obj[props[z]] + tip[z] - scroll[z]) > size[z] - this.options.windowPadding[z]){ - obj[props[z]] = event.page[z] - this.options.offset[z] - tip[z]; + obj[props[z]] = event.page[z] - offset - tip[z]; bounds[z+'2'] = true; } }