UNPKG

2.19 kBMarkdownView Raw
1## Why You Should Use Tether
2
3Virtually every app includes some sort of overlay attached to an element on the page.
4Things like [tooltips](http://github.hubspot.com/tooltip/docs/welcome),
5[dropdowns](http://github.hubspot.com/select/docs/welcome), [hover-activated info boxes](http://github.hubspot.com/drop/docs/welcome), etc.
6
7Those elements need to be attached to something on the page. Actually placing them next to
8the element in the DOM causes problems though, if any parent element is anything
9but `overflow: visible`, the element gets cut off. So you need absolute positioning
10in the body.
11
12Some of the time absolute positioning is right, but what about if the thing we're
13attached to is fixed to the center of the screen? We'll have to move it every
14time the user scrolls. What about if the element is in a scrollable container,
15if the overlay is inside of it (so no clipping), it would be cool if the code
16were smart enough to move it inside when that area is scrolled. That way we
17need to reposition it even less.
18
19It would also be nice if the code could somehow figure out whether positioning it
20from the top, bottom, left, or right would result in the fewest repositionings
21as the user scrolls or resizes.
22
23Most of the time you're building these elements it would be nice for the element to
24flip to the other side of the element if it hits the edge of the screen, or a scrollable
25container it might be in. It would be nice if we could confine the element
26to within some area, or even hide it when it leaves.
27
28It would be nice for the element to be repositioned with CSS transforms
29rather than top and left when possible, to allow the positioning to be done entirely
30in the GPU.
31
32Now that the positioning is so fancy, you're going to use it for more and more
33elements. It would be cool if the library could optimize all of their repositioning
34into a single repaint.
35
36All of that is baked into Tether.
37
38### tl;dr
39
40- Optimized GPU-accelerated repositioning for 60fps scrolling
41- Reliable positioning on any possible corner, edge or point in between.
42- Support for repositioning or pinning the element when it would be offscreen
43- Designed to be embeddable in other libraries