1
1
# vue-overlay
2
2
3
- To mask out the background when a dialog / modal or similar is opened, a overlay is needed.
3
+ > To mask out the background when a dialog / modal or similar is opened, a overlay is needed.
4
4
5
5
### [ Demo] ( https://vue-comps.github.io/vue-overlay )
6
6
7
+ ### Features
8
+ - singleton & z-index management to allow stacking
9
+ - background doesn't move when scroll gets disabled
10
+
7
11
### Used in
8
12
- [ side-nav] ( https://vue-comps.github.io/vue-side-nav )
9
13
- [ modal] ( https://vue-comps.github.io/vue-comps-modal )
@@ -17,31 +21,44 @@ or include `build/bundle.js`.
17
21
18
22
## Usage
19
23
``` coffee
20
- # overlay is a singleton and is designed
21
- # to be used in different places simultaniously
22
24
overlay = require (" vue-overlay" )(Vue)
23
25
# or, when using bundle.js
24
26
overlay = window .vueComps .overlay
27
+ ```
28
+ For examples see [ ` dev/ ` ] ( dev/ ) .
29
+ If you need to reliable get the ` Vue ` instance, see [ vue-mixins/vue] ( https://github.com/paulpflug/vue-mixins#vue )
30
+
31
+ {zIndex, close} = overlay.open(options)
32
+ ---
33
+ - ` zIndex ` - the z-index of the opened overlay - will be raised by 5 for each overlay
34
+ - ` close(callHooks=true) ` - shortcut for ` overlay.close(options,callHooks) ` - options will be the same instance used for opening
35
+ - ` Options `
36
+
37
+ | Name | type | default | description |
38
+ | ---:| --- | ---| --- |
39
+ | opacity | Number | 0.5 | opacity of the overlay |
40
+ | dismissable | Boolean | true | is the overlay dismissable by click or ESC? |
41
+ | onBeforeOpen | Function | null | hook before open animation |
42
+ | onOpened | Function | null | hook after open animation |
43
+ | onBeforeClose | Function | null | hook before close animation |
44
+ | onClosed | Function | null | hook after close animation |
45
+ | allowScroll | Boolean | false | don't set ` overflow:hidden ` on body |
46
+ | color | String | "black" | background-color of the overlay |
47
+
48
+ overlay.close(options=lastOverlay, callHooks=true)
49
+ ---
50
+ - ` options ` the options object which was used to open a overlay
51
+ - ` callHooks ` set to ` false ` to suppress the calls of ` onBeforeClose ` and ` onClosed ` of that overlay
25
52
26
- # returns the z-index of the overlay + 1 (starts with 1001)
27
- # and a function to close this specific overlay
28
- {zIndex ,close } = overlay .open (options)
29
- overlay .open () # z-index will raise by 5
30
-
31
- # close hooks of the first options object will be called
32
- # and z-index will be lowered by 5
33
- overlay .close ()
34
- overlay .close () # overlay really closes
35
-
36
- # To close a specific overlay you can use
37
- overlay .close (options) # where options must be the same object which is used to open
38
- # or use the result from open
39
- {close } = overlay .open ()
40
- close ()
41
-
42
- # the overlay comes without animation, but you can easily set them up,
43
- # for example with velocity.js:
44
- Velocity = require (" velocity-animate" )
53
+ overlay.fade({el,opacity,cb})
54
+ ---
55
+ overwrite to add a animation
56
+ - ` el ` the ` div ` element of the overlay
57
+ - ` opacity ` the target opacity of the opening/closing
58
+ - ` cb ` a function which must be called when finished
59
+
60
+ example:
61
+ ``` coffee
45
62
overlay .fade = ({el,opacity,cb}) ->
46
63
Velocity el, {opacity : opacity},
47
64
{
@@ -52,17 +69,9 @@ overlay.fade = ({el,opacity,cb}) ->
52
69
}
53
70
```
54
71
55
- For examples see [ ` dev/ ` ] ( dev/ ) .
56
- #### Options
57
- | Name | type | default | description |
58
- | ---:| --- | ---| --- |
59
- | opacity | Number | 0.5 | opacity of the overlay |
60
- | dissmissible | Boolean | true | is the overlay dissmissible by click or ESC? |
61
- | onBeforeOpen | Function | null | hook before open animation |
62
- | onOpened | Function | null | hook after open animation |
63
- | onBeforeClose | Function | null | hook before close animation |
64
- | onClosed | Function | null | hook after close animation |
65
- | allowScroll | Boolean | false | don't set ` overflow:hidden ` on body |
72
+
73
+
74
+
66
75
67
76
# Development
68
77
Clone repository
0 commit comments