|
2 | 2 |
|
3 | 3 | A simple package to reveal some extra information on hover
|
4 | 4 |
|
5 |
| -> ⚠ **This package is still under development** |
6 |
| -> |
7 |
| -> Although it's in a usable state, there is still a little work to do - just to refine it |
8 |
| -> - Primarily, there is CSS to add to the package, document changes and some more testing |
9 |
| -> - For now, you can implement the styling how you see fit and submit issues for any problems you find |
| 5 | +### Links |
| 6 | +- [Change log](./CHANGELOG.md) |
| 7 | +- [License (MIT)](./LICENSE) |
10 | 8 |
|
11 | 9 | ## Usage
|
12 | 10 |
|
13 | 11 | Add the below to your code to your project and you're away
|
14 | 12 |
|
15 | 13 | ```TS
|
16 |
| -const hB = new HoverBox(".HoverBox"); |
| 14 | +const hb = new HoverBox(".HoverBox"); |
| 15 | +const hbWithOptions = new HoverBox(".HoverBox", options); // if you have options |
17 | 16 |
|
18 | 17 | // Inside some other functions somewhere
|
19 |
| -hB.startListening(); |
20 |
| -hB.stopListening(); |
| 18 | +hb.startListening(); |
| 19 | +hb.stopListening(); |
21 | 20 | ```
|
22 | 21 |
|
23 |
| -## Changes |
| 22 | +## Options |
24 | 23 |
|
25 |
| -You can see all the changes in our [change log](./CHANGELOG.md) |
| 24 | +Option | Type | Default | Description |
| 25 | +---|---|---|--- |
| 26 | +setMy? | [Type: pA][PositionAlignment] | `top center` | The part of the popup linked the anchor |
| 27 | +at? | [Type: pA][PositionAlignment] | `bottom center` | The part of the anchor that the target should link to |
| 28 | +keepOpen? | boolean | `true` | If the mouse moves into the popup, keep it open |
| 29 | +allowHtml? | boolean | `false` | The text provided can be treated as safe HTML |
| 30 | +transitionDelay? | number | `333` | The delay before we start the transition |
| 31 | +transitionDuration? | number | `333` | Must match the CSS transition property |
| 32 | +**HoverPosition specific** |
| 33 | +collision? | [PositionCollision](#type-positioncollision) | `bestfit` | How to handle the popup colliding with the window edge |
| 34 | +bestFitPreference? | `horizontal` OR `vertical` | `horizontal` | The preferred direction to try `bestfit` first |
| 35 | +defaults? | { my: [pA][PositionAlignment]; at: [pA][PositionAlignment]; } | Same as `setMy` & `at` respectively | Defaults to use if parsing of `setMy` or `at` fails |
26 | 36 |
|
27 |
| -## License |
| 37 | +### Type: `PositionAlignment` |
28 | 38 |
|
29 |
| -This extension is licensed under the [MIT License](./LICENSE) |
| 39 | +Where to position an element. Use either: `top`, `bottom`, `center`, `left` or `right`. You can also specify a vertical and horizontal alignment like `top right`, `bottom right` or `center left`. |
| 40 | + |
| 41 | + |
| 42 | +Using a single value will default the other to `center` so `left` == `center left` |
| 43 | + |
| 44 | +### Type: `PositionCollision` |
| 45 | + |
| 46 | +How to handle any collisions, either: |
| 47 | + |
| 48 | +- `bestFit`: find the best fit before trying to flip the element |
| 49 | +- `flipFit`: flip the element completely vertically and horizontally |
| 50 | +- `ignore`: ignore any collisions and just carry on |
| 51 | + |
| 52 | + |
| 53 | +[PositionAlignment]: #type-positionalignment |
0 commit comments