-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodal.coffee
84 lines (78 loc) · 1.66 KB
/
modal.coffee
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ceri = require "ceri/lib/wrapper"
module.exports = ceri
mixins: [
require "ceri/lib/props"
require "ceri/lib/style"
require "ceri/lib/open"
require "ceri/lib/overlay"
]
props:
opacity:
type: Number
default: 0.5
keepOpen:
type: Boolean
zIndex:
type: Number
default: 1500
bottomSheet:
type: Boolean
attach:
type: String
events:
click:
target:
active: -> @target and !@openingOrOpen
notPrevented: true
prevent: true
cbs: "show"
destroy: true
computed:
target: ->
if @attach
return document.querySelector(@attach)
else if @attach?
if @__placeholder.previousElementSibling
return @__placeholder.previousElementSibling
else
return @__parentElement
return null
data: ->
onBody: true
overlay:
zIndex: "zIndex"
active: "openingOrOpen"
animate: "toggleAnimate"
keepOpen: "keepOpen"
delay: true
onClose: "hide"
onOpen: (zIndex) -> @style.zIndex = zIndex+1
initStyle:
position: "fixed"
left: 0
right: 0
display: "block"
methods:
enter: (o) ->
if @bottomSheet
o.style =
bottom: [-100,0,"%"]
opacity: [0,1]
else
o.style =
top: [4,10,"%"]
opacity: [0,1]
scaleX: [0.7,1]
return @$animate(o)
leave: (o) ->
o.duration = 200
if @bottomSheet
o.style =
bottom: [0,-100,"%"]
opacity: [1,0]
else
o.style =
top: [10,4,"%"]
opacity: [1,0]
scaleX: [1,0.7]
return @$animate(o)