Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Tips fix #1019

wants to merge 2 commits into from

3 participants


Made it possible to supply a function for the tips offset option. This is so it can be calculated dynamically.
This is a fix to the problem described here:

but I think it is a good idea to have this mechanism in other places where only static values are accepted.


great :) thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +1 −1  Docs/Interface/
  2. +5 −3 Source/Interface/Tips.js
2  Docs/Interface/
@@ -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.
8 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]] =[z] + this.options.offset[z];
+ offset = this.options.offset[z].call ? this.options.offset[z].call(this) : this.options.offset[z];
+ obj[props[z]] =[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]] =[z] - this.options.offset[z] - tip[z];
+ obj[props[z]] =[z] - offset - tip[z];
bounds[z+'2'] = true;
Something went wrong with that request. Please try again.