Skip to content

Commit 23edc74

Browse files
committed
Refactoring
- Simplify `defaultOptions` to just `options` to better reflect the norm - Removed null check as the property can never actually be null
1 parent 1703037 commit 23edc74

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export class HoverBox {
1010
/**
1111
* Setup hoverbox events and start listening
1212
* @param selector The selector to find the child that contains the text to show
13-
* @param defaultOptions The default options to apply
13+
* @param options The default options to apply
1414
*/
15-
constructor(selector: string, defaultOptions?: HoverOptions) {
15+
constructor(selector: string, options?: HoverOptions) {
1616
this._selector = selector;
17-
this._options = Object.assign({}, defaultOptions);
17+
this._options = Object.assign({}, options);
1818
this._timeouts = {};
1919

2020
this.startListening();
@@ -65,7 +65,7 @@ export class HoverBox {
6565
private handleHoverBoxAnimation(t: HTMLElement, showOrHide: 'show' | 'hide'): void {
6666
const hoverBox = this.getHoverBox(t, showOrHide);
6767

68-
if (hoverBox === null) {
68+
if (!hoverBox) {
6969
return;
7070
}
7171

@@ -79,9 +79,9 @@ export class HoverBox {
7979
at: this._options.at ?? 'bottom center',
8080
anchor: t,
8181
target: hoverBox,
82-
collision: this._options?.collision,
83-
bestFitPreference: this._options?.bestFitPreference,
84-
defaults: this._options?.defaults,
82+
collision: this._options.collision,
83+
bestFitPreference: this._options.bestFitPreference,
84+
defaults: this._options.defaults,
8585
});
8686

8787
// apply new position

0 commit comments

Comments
 (0)