-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathstate.js
49 lines (41 loc) · 1.13 KB
/
state.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
/* eslint-disable ember/no-computed-properties-in-native-classes */
import EmberObject, { action, computed } from '@ember/object';
import getAnimation from 'ember-burger-menu/animations';
import { tracked } from '@glimmer/tracking';
export default class State extends EmberObject {
@tracked open = false;
@tracked locked = false;
@tracked width = 300;
@tracked position = 'left';
@tracked animation = 'slide';
@tracked minSwipeDistance = 150;
@tracked maxSwipeTime = 300;
@tracked itemAnimation = null;
@tracked customAnimation = null;
@computed('animation', 'itemAnimation', 'customAnimation')
get styles() {
const { animation, itemAnimation, customAnimation } = this;
return getAnimation(customAnimation || animation, itemAnimation).create();
}
@action
openMenu(event) {
event?.stopPropagation?.();
if (!this.locked) {
this.open = true;
}
}
@action
closeMenu(event) {
event?.stopPropagation?.();
if (!this.locked) {
this.open = false;
}
}
@action
toggleMenu(event) {
event?.stopPropagation?.();
if (!this.locked) {
this.open = !this.open;
}
}
}