Skip to content

Commit ef731a6

Browse files
committed
types definition enhancements
1 parent 8f00e91 commit ef731a6

4 files changed

+28
-27
lines changed

src/get-layout-dimensions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const getLayoutOuterDimensions = (element, scroller) => {
2424
* @example
2525
* getLayoutDimensions(document.querySelector('div')) // --> { outerHeight: 123, ... }
2626
* @param {HTMLElement} element - The given element whose dimensions need to be retrieved.
27-
* @param {Client|HTMLElement} scroller - The given scrollable used to retrieve some
27+
* @param {GlobalContext|HTMLElement} scroller - The given scrollable used to retrieve some
2828
* dimensions when the given element is global (page).
2929
* @returns {LayoutDimensions} The given element dimensions as an object ({ top, left }).
3030
*/

src/get-scroll-position.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import './typedef.js';
55
* @public
66
* @example
77
* getScrollPosition(document.queryselector('div')); // --> { top: 123, left: 345 }
8-
* @param {Client|HTMLElement} element - The given element whose scroll
8+
* @param {GlobalContext|HTMLElement} element - The given element whose scroll
99
* position needs to be retrieved.
1010
* @returns {ScrollPosition} The given element scroll position
1111
* as an object ({ top, left }).

src/scroll-padlock.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ class ScrollPadlock {
7070
* @public
7171
* @throws {TypeError} Throws when the given constructor arguments are invalid.
7272
* @throws {Error} Throws when an instance is already attached to the given dom element.
73-
* @param {HTMLElement | ScrollPadlockOptions} [scrollingElementArgument] - The given scrollable
73+
* @param {HTMLElement|ConstructorOptions} [scrollingElementArgument] - The given scrollable
7474
* element whose scroll needs to be controlled or an options object.
7575
* @param {string} [cssClassNameArgument] - The locked-state css class or an options object.
76-
* @param {Client} [clientArgument] - The client environment object (window).
76+
* @param {GlobalContext} [clientArgument] - The client environment object (window).
7777
*/
7878
constructor(scrollingElementArgument, cssClassNameArgument, clientArgument = globalThis) {
7979
// The Padlock first argument type
@@ -303,7 +303,7 @@ class ScrollPadlock {
303303
/**
304304
* A reference to the client "window" object.
305305
* @private
306-
* @type {Client}
306+
* @type {GlobalContext}
307307
* @memberof ScrollPadlock
308308
*/
309309
#window = null;
@@ -382,15 +382,15 @@ class ScrollPadlock {
382382

383383
/**
384384
* The current scroll position.
385-
* @type {Types.ScrollPosition}
385+
* @type {ScrollPosition}
386386
* @private
387387
* @memberof ScrollPadlock
388388
*/
389389
#scrollCurrent = null;
390390

391391
/**
392392
* The scroll position saving, the scroll position stored for later use.
393-
* @type {Types.ScrollPosition}
393+
* @type {ScrollPosition}
394394
* @private
395395
* @memberof ScrollPadlock
396396
*/
@@ -475,7 +475,7 @@ class ScrollPadlock {
475475
* const padlock = new ScrollPadlock();
476476
*
477477
* padlock.scroll // --> { top: 123, left: 345 }
478-
* @returns {Types.ScrollPosition} The current scroll position object or the
478+
* @returns {ScrollPosition} The current scroll position object or the
479479
* scroll position previously saved if on a locked state.
480480
*/
481481
get scroll() {
@@ -492,7 +492,7 @@ class ScrollPadlock {
492492
* const padlock = new ScrollPadlock();
493493
*
494494
* padlock.scroll = { top: 123, left: 345 }
495-
* @param {Types.ScrollPosition} position - The scroll position to be set
495+
* @param {ScrollPosition} position - The scroll position to be set
496496
* or saved if on a locked state.
497497
*/
498498
set scroll(position) {
@@ -517,7 +517,7 @@ class ScrollPadlock {
517517
* const padlock = new ScrollPadlock();
518518
*
519519
* padlock.layout // --> { outerHeight: 123, outerWidth: 345, innerWidth: 123, ... }
520-
* @returns {Types.Layout} The layout object.
520+
* @returns {LayoutDimensions} The layout object.
521521
*/
522522
get layout() {
523523
return this.#layout;
@@ -578,7 +578,7 @@ class ScrollPadlock {
578578
* Window resize event handler, bound with the wrapper function.
579579
* @private
580580
* @memberof ScrollPadlock
581-
* @type {Handler}
581+
* @type {EventHandler}
582582
*/
583583
#handleResize = this.#resizeHandler.bind(this);
584584

@@ -600,7 +600,7 @@ class ScrollPadlock {
600600
* Element scroll event handler, bound with the wrapper function.
601601
* @private
602602
* @memberof ScrollPadlock
603-
* @type {Handler}
603+
* @type {EventHandler}
604604
*/
605605
#handleScroll = this.#scrollHandler.bind(this);
606606

@@ -620,7 +620,7 @@ class ScrollPadlock {
620620
* Scrolls the given element to a given scroll position.
621621
* @private
622622
* @memberof ScrollPadlock
623-
* @param {Types.ScrollPosition} position - The scroll position to be set.
623+
* @param {ScrollPosition} position - The scroll position to be set.
624624
* @returns {void} Nothing.
625625
*/
626626
#scrollTo = (position) => this.#scrollEventElement?.scrollTo(
@@ -679,7 +679,7 @@ class ScrollPadlock {
679679
* Updates the layout object.
680680
* @private
681681
* @memberof ScrollPadlock
682-
* @returns {Types.ScrollPosition} The layout object.
682+
* @returns {LayoutDimensions} The layout object.
683683
*/
684684
#updateLayout() {
685685
// If the elements involved are set (if not the instance has been probably destroyed)
@@ -696,7 +696,7 @@ class ScrollPadlock {
696696
* Refresh the scroll position at a (temporarly) unlocked state.
697697
* @private
698698
* @memberof ScrollPadlock
699-
* @returns {Types.ScrollPosition} The current scroll position object.
699+
* @returns {ScrollPosition} The current scroll position object.
700700
*/
701701
#updateScrollCurrent() {
702702
// If the involved element is set (if not the instance has been probably destroyed)

src/typedef.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,28 @@
1717
*/
1818

1919
/**
20-
* @typedef Client
20+
* @typedef GlobalContext
2121
* @type {Window & typeof globalThis}
2222
*/
2323

2424
/**
25-
* @callback Handler
25+
* @callback EventHandler
2626
* @returns {void}
2727
*/
2828

2929
/**
30-
* @callback HandlerWrapper
31-
* @param {Handler} predicate
32-
* @returns {Handler}
30+
* @callback EventHandlerWrapper
31+
* @param {EventHandler} predicate - The original handler function.
32+
* @returns {EventHandler}
3333
*/
3434

3535
/**
36-
* @typedef ScrollPadlockOptions
37-
* @property {HTMLElement} scrollingElement Asd.
38-
* @property {Client | HTMLElement} scrollEventElement Asd.
39-
* @property {string} cssClassName Asd.
40-
* @property {HandlerWrapper} resizeHandlerWrapper Asd.
41-
* @property {HandlerWrapper} scrollHandlerWrapper Asd.
42-
* @property {Client} client Asd.
36+
* @typedef ConstructorOptions
37+
* @property {HTMLElement} scrollingElement The html element that can perform the scrolling action.
38+
* @property {GlobalContext|HTMLElement} scrollEventElement The element that can
39+
* perform and listen to scroll event.
40+
* @property {string} cssClassName The lock state CSS class name.
41+
* @property {EventHandlerWrapper} resizeHandlerWrapper The "resize" event handler function wrapper.
42+
* @property {EventHandlerWrapper} scrollHandlerWrapper The "scroll" event handler function wrapper.
43+
* @property {GlobalContext} client A reference to the client "window" object.
4344
*/

0 commit comments

Comments
 (0)