forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfab-list.tsx
More file actions
58 lines (49 loc) · 1.51 KB
/
fab-list.tsx
File metadata and controls
58 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Prop, Watch, h } from '@stencil/core';
import { getIonMode } from '../../global/ionic-global';
@Component({
tag: 'ion-fab-list',
styleUrl: 'fab-list.scss',
shadow: true,
})
export class FabList implements ComponentInterface {
@Element() el!: HTMLIonFabElement;
private activateTimeouts: ReturnType<typeof setTimeout>[] = [];
/**
* If `true`, the fab list will show all fab buttons in the list.
*/
@Prop() activated = false;
@Watch('activated')
protected activatedChanged(activated: boolean) {
this.activateTimeouts.forEach(clearTimeout);
this.activateTimeouts = [];
const fabs = Array.from(this.el.querySelectorAll('ion-fab-button'));
// if showing the fabs add a timeout, else show immediately
const timeout = activated ? 30 : 0;
fabs.forEach((fab, i) => {
this.activateTimeouts.push(setTimeout(() => (fab.show = activated), i * timeout));
});
}
/**
* The side the fab list will show on relative to the main fab button.
*/
@Prop() side: 'start' | 'end' | 'top' | 'bottom' = 'bottom';
disconnectedCallback() {
this.activateTimeouts.forEach(clearTimeout);
this.activateTimeouts = [];
}
render() {
const mode = getIonMode(this);
return (
<Host
class={{
[mode]: true,
'fab-list-active': this.activated,
[`fab-list-side-${this.side}`]: true,
}}
>
<slot></slot>
</Host>
);
}
}