Current proposal
#position(x, y) , #position(element)
Should only re-position the tooltip to x,y coordinates, or element. It shouldn't do any attaching under the hood, and should be oblivious to any active attachment.
#attach(target)
Should attach the tooltip to various things, and set up the most appropriate automatic re-positioning for given target:
element - should update on window resize and scroll
cursor - should update on cursor movement
All updates obviously throttled by rAF.
#detach()
Should cancel active attachment, and remove the tooltip from listeners.
#show()
Currently does too many things. Re-positions stuff when tooltip is attached, make this._aware() calls.
Ideally it should only attach tooltip element to body, and set this.hidden flag to false. Possibly notify attached target watchers about a change so they reposition the tip? Sounds too convoluted :/
Needs more thought.
#hide()
Ideally should only set the this.hidden flag to true, and remove tooltip element from DOM.
Currently, it does calls to this._unaware() which should be removed altogether.
Issues
- When tooltip is hidden, re-positioning doesn't happen. In this state the attachment target might change position. Than when
#show() is called, tooltip will be at the wrong place.
#show() is currently doing #position(this._attachedTo) when tooltip is attached. This won't work, or be horrible when #attach('cursor') is implemented.
Current proposal
#position(x, y) , #position(element)
Should only re-position the tooltip to x,y coordinates, or element. It shouldn't do any attaching under the hood, and should be oblivious to any active attachment.
#attach(target)
Should attach the tooltip to various things, and set up the most appropriate automatic re-positioning for given target:
element- should update on window resize and scrollcursor- should update on cursor movementAll updates obviously throttled by rAF.
#detach()
Should cancel active attachment, and remove the tooltip from listeners.
#show()
Currently does too many things. Re-positions stuff when tooltip is attached, make
this._aware()calls.Ideally it should only attach tooltip element to body, and set
this.hiddenflag tofalse. Possibly notify attached target watchers about a change so they reposition the tip? Sounds too convoluted :/Needs more thought.
#hide()
Ideally should only set the
this.hiddenflag totrue, and remove tooltip element from DOM.Currently, it does calls to
this._unaware()which should be removed altogether.Issues
#show()is called, tooltip will be at the wrong place.#show()is currently doing#position(this._attachedTo)when tooltip is attached. This won't work, or be horrible when#attach('cursor')is implemented.