-
Notifications
You must be signed in to change notification settings - Fork 0
/
cork-toggle-panel.js
50 lines (41 loc) · 1005 Bytes
/
cork-toggle-panel.js
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
import {PolymerElement} from "@polymer/polymer/polymer-element"
import "@polymer/iron-icon/iron-icon"
import "@polymer/iron-icons/iron-icons"
import template from "./cork-toggle-panel.html"
export class CorkTogglePanel extends PolymerElement {
static get properties() {
return {
opened: {
type: Boolean,
value: false,
notify : true
},
label: {
type : String,
value : ''
}
};
}
static get template() {
let tag = document.createElement('template');
tag.innerHTML = template;
return tag;
}
open() {
var h = 5;
for( var i = 0; i < this.children.length; i++ ) {
h += this.children[i].offsetHeight;
}
this.$.content.style.height = h+'px';
this.opened = true;
}
close() {
this.$.content.style.height = '0px';
this.opened = false;
}
toggle() {
if( this.opened ) this.close();
else this.open();
}
}
customElements.define('cork-toggle-panel', CorkTogglePanel);