15.1.0 • Published 10 months ago

@zestia/ember-async-tooltips v15.1.0

Weekly downloads
9
License
MIT
Repository
github
Last release
10 months ago

@zestia/ember-async-tooltips

Latest npm release Ember Observer

Installation

ember install @zestia/ember-async-tooltips

Demo

https://zestia.github.io/ember-async-tooltips

Features

  • Manual positioning ✔︎
  • Automatic positioning ✔︎
  • Customisable show/hide delays ✔︎
  • Customisable reference element ✔︎
  • Customisable destination element ✔︎
  • Pre-loads any required data ✔︎
  • Tethers to element ✔︎

Notes

  • This addon intentionally does not come with any styles.
  • It is configured with ember-test-waiters so awaiting in your test suite will just work.

Example

<div>
  Hover over me

  <Tooltip>
    Hello World
  </Tooltip>
</div>

Tooltip

Arguments

@element

Optional. By default, the parent of the tooltip element is what causes the tooltip to show & hide, and is also the element it will be positioned next to.

@destination

Optional. By default, tooltips are rendered in-place. Specify a destination if you want to render them in that element instead.

@attachTo

Optional. By default, tooltips will be positioned next to the element that caused them to display. Unless this argument is specified, in which case the tooltip will show when mousing over the element, but will then be positioned next to a different element.

@show

Optional. By default, tooltips will display when hovering over the reference element. But you can use this argument to force a tooltip to display.

@showDelay

Optional. The show delay will prevent the tooltip from being shown until the specified milliseconds have passed after entering the reference element.

@hideDelay

Optional. The hide delay will prevent the tooltip from being hidden until the specified milliseconds have passed after leaving the reference element.

@stickyID

Optional. You can group tooltips together with a sticky identifier. When a tooltip from a group of tooltips all with the same identifier is shown, then other tooltips in that group will show instantly - ignoring their show delay. The term sticky is used because it feels as if the tooltips are stuck open.

@stickyTimeout

Optional. When a group of tooltips is in sticky mode (and so they have no show delays), after a period of time they will revert back to their normal delays. Use this argument to tweak that behaviour.

@onLoad

Optional. When an element is hovered over, @onLoad will be fired. You can respond to this action by returning a promise. The result of that promise is available on the API. This is a good way preload any data required for the tooltip to display.

In the following example, there is a show delay of 300ms before a tooltip will appear. But, during that time it is loading some data which takes 50ms. The actual show delay is reduced to 250ms, so that the total delay remains at 300ms.

```handlebars
{{! user-tooltip.hbs }}
<Tooltip @showDelay={{300}} @onLoad={{fn this.loadUser @id}} as |tooltip|>
  {{tooltip.data.user.name}}
</Tooltip>

@onShow

Optional. Fired after a tooltip has been rendered, and any animations have been performed.

@onHide

Optional. Fired after any animations have been performed, and the tooltip has been destroyed.

@eager

Optional. If true, @onLoad is fired when the mouse enters the reference element, this is so data required for the tooltip to display will arrive sooner. When false, @onLoad is fired when the tooltip displays. Defaults to true.

@position

Optional. Tooltips will be automatically positioned around the outside edge of the element if no @position is specified.

For example: If the element is positioned in the 'bottom left' of the viewport, then the tooltip will be displayed above, so as to remain visible.

You can use the arguments @rows and @columns to tweak how the positioning algorithm decides what 'bottom left' means. See the positioning library for more information.

You can also set @position to be a function. It will receive the element's position in the viewport. You are then free to return an appropriate counter position for your tooltip.

position(referencePosition) {
  switch(referencePosition) {
    case 'top right':
      return 'left top';
    // ...
  }
}

API

hide

Hides the tooltip (waiting for any animations), then un-renders it.

data

Any data that was loaded via @onLoad

error

Any error if the data was @onLoad failed

Animating

If your tooltips need to animate in and out, you can utilise these attributes:

[data-showing='true'] {
  animation: your-show-animation;
}

[data-showing='false'] {
  animation: your-hide-animation;
}

You may want to alter animations for sticky tooltips:

[data-sticky='true'] {
  animation-name: none;
}
15.1.0

10 months ago

14.5.0

2 years ago

14.4.0-0

2 years ago

15.0.2

1 year ago

15.0.0

1 year ago

15.0.1

1 year ago

14.6.0

2 years ago

14.6.1

2 years ago

15.0.0-beta.3

1 year ago

15.0.0-beta.4

1 year ago

15.0.0-beta.1

1 year ago

15.0.0-beta.2

1 year ago

15.0.0-beta.5

1 year ago

15.0.0-beta.6

1 year ago

15.0.0-beta.0

1 year ago

14.4.0

2 years ago

14.4.1

2 years ago

14.3.2

2 years ago

14.3.0

3 years ago

14.3.1

3 years ago

14.2.0

3 years ago

14.2.1

3 years ago

14.1.4-beta.2

3 years ago

14.1.4-beta.1

3 years ago

14.1.4-beta.0

3 years ago

14.1.3

3 years ago

14.1.2

3 years ago

14.1.1

3 years ago

14.1.0

3 years ago

14.0.0

3 years ago

13.3.0

3 years ago

13.2.3

3 years ago

13.2.2

3 years ago

13.2.0

3 years ago

13.2.1

3 years ago

13.1.0

3 years ago

13.0.6

3 years ago

13.0.5

4 years ago

13.0.4

4 years ago

13.0.3

4 years ago

13.0.2

4 years ago

13.0.1

4 years ago

13.0.0

4 years ago

12.0.4

4 years ago

12.0.3

4 years ago

12.0.2

4 years ago

12.0.0

4 years ago

12.0.1

4 years ago

11.0.2

4 years ago

11.0.1

4 years ago

11.0.0

4 years ago

10.0.4

4 years ago

10.0.3

4 years ago

10.0.2

4 years ago

10.0.1

4 years ago

10.0.0

4 years ago

9.1.5-beta.10

4 years ago

9.1.5-beta.7

5 years ago

9.1.5-beta.6

5 years ago

9.1.5-beta.5

5 years ago

9.1.5-beta.4

5 years ago

9.1.5-beta.3

5 years ago

9.1.5-beta.2

5 years ago

9.1.5-beta.1

5 years ago

9.1.5-beta.0

5 years ago

9.1.4

5 years ago

9.1.3

5 years ago

9.1.2

5 years ago

9.1.1

5 years ago

9.1.0

5 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.0.4

5 years ago

8.0.3

5 years ago

8.0.2

5 years ago

8.0.0

5 years ago

7.2.0

5 years ago

7.1.0

5 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

5.2.4

5 years ago

5.2.3

5 years ago

5.2.2

6 years ago

5.2.1

6 years ago

5.2.0

6 years ago

5.1.0

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.9

6 years ago

4.0.8

6 years ago

4.0.7

6 years ago

4.0.6

6 years ago

4.0.5

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago