Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethink position, attach, detach, show, and hide methods #17

Open
darsain opened this issue Mar 11, 2015 · 1 comment
Open

Rethink position, attach, detach, show, and hide methods #17

darsain opened this issue Mar 11, 2015 · 1 comment
Milestone

Comments

@darsain
Copy link
Owner

darsain commented Mar 11, 2015

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.
@darsain darsain added this to the 1.0 milestone May 31, 2015
@darsain darsain changed the title Rethink #position() #attachTo() #detach() methods Rethink position, attach, detach, show, and hide methods May 31, 2015
@darsain
Copy link
Owner Author

darsain commented Aug 8, 2015

Or, a quite different API rethink altogether:

  1. Remove show/hide methods, replace with only one, #destroy().
  2. There is no concept of hidden tooltip anymore.
  3. Tooltip either exists, and is visible, or it doesn't.

This will force developers to never hide tooltips, or keep Tooltip instances that are hidden. They'll just be discarded, releasing the memory.

Gonna look for reasons why this is a bad idea :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant