diff options
Diffstat (limited to 'src/Layout.mjs')
-rw-r--r-- | src/Layout.mjs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs index 5236475..7b14926 100644 --- a/src/Layout.mjs +++ b/src/Layout.mjs | |||
@@ -2,13 +2,17 @@ import PlainDraggable from 'plain-draggable' | |||
2 | import { onRemove, animateRectTransition } from './utils' | 2 | import { onRemove, animateRectTransition } from './utils' |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * Layout. Basic class for layout | 5 | * Basic class for layout |
6 | */ | 6 | */ |
7 | export class Layout { | 7 | export class Layout { |
8 | /** | 8 | /** |
9 | * constructor. | 9 | * Creates a new Layout instance |
10 | * | 10 | * |
11 | * @param {} options | 11 | * @param {Object} options - The options for the layout |
12 | * @param {string} options.name - The name of the layout | ||
13 | * @param {Function} [options.enterHandler] - Handler called when entering the layout | ||
14 | * @param {Function} [options.leaveHandler] - Handler called when leaving the layout | ||
15 | * @throws {Error} If the layout name is not provided | ||
12 | */ | 16 | */ |
13 | constructor (options = {}) { | 17 | constructor (options = {}) { |
14 | if (!options.name) throw Error('Layout name is not given') | 18 | if (!options.name) throw Error('Layout name is not given') |
@@ -18,7 +22,9 @@ export class Layout { | |||
18 | } | 22 | } |
19 | 23 | ||
20 | /** | 24 | /** |
21 | * valueOf. | 25 | * Returns the name of the layout |
26 | * | ||
27 | * @returns {string} The name of the layout | ||
22 | */ | 28 | */ |
23 | valueOf = () => this.name | 29 | valueOf = () => this.name |
24 | } | 30 | } |
@@ -35,9 +41,12 @@ export class SideBySide extends Layout { | |||
35 | name = 'side-by-side' | 41 | name = 'side-by-side' |
36 | 42 | ||
37 | /** | 43 | /** |
38 | * enterHandler. | 44 | * Handler called when entering the Side-By-Side layout |
39 | * | 45 | * |
40 | * @param {} | 46 | * @param {Object} options - The options object |
47 | * @param {HTMLElement} options.container - The main container element | ||
48 | * @param {HTMLElement} options.htmlHolder - The HTML content holder | ||
49 | * @param {HTMLElement} options.showcase - The showcase element | ||
41 | */ | 50 | */ |
42 | enterHandler = ({ container, htmlHolder, showcase }) => { | 51 | enterHandler = ({ container, htmlHolder, showcase }) => { |
43 | const bar = document.createElement('div') | 52 | const bar = document.createElement('div') |
@@ -71,9 +80,10 @@ export class SideBySide extends Layout { | |||
71 | } | 80 | } |
72 | 81 | ||
73 | /** | 82 | /** |
74 | * leaveHandler. | 83 | * Handler called when leaving the Side-By-Side layout |
75 | * | 84 | * |
76 | * @param {} | 85 | * @param {Object} options - The options object |
86 | * @param {HTMLElement} options.container - The main container element | ||
77 | */ | 87 | */ |
78 | leaveHandler = ({ container }) => { | 88 | leaveHandler = ({ container }) => { |
79 | container.querySelector('.bar')?.remove() | 89 | container.querySelector('.bar')?.remove() |