vue-overlay

a simple overlay
2,750 5
Install
npm install vue-overlay
Latest Version:2.0.0
Vue:2
Older releases:1
License:MIT
Last Updated:Mar 24, 2017
Links: GitHub  ·  npm
Maintainer: paulpflug

vue-overlay

To mask out the background when a dialog / modal or similar is opened, a overlay is needed.

Demo

Features

  • singleton & z-index management to allow stacking
  • background doesn't move when scroll gets disabled

Used in

Install

npm install --save-dev vue-overlay
// vue@1.0
npm install --save-dev vue-overlay@1

or include build/bundle.js.

Usage

overlay = require("vue-overlay")(Vue)
# or, when using bundle.js
overlay = window.vueComps.overlay

For examples see dev/. If you need to reliable get the Vue instance, see vue-mixins/vue

{zIndex, close} = overlay.open(options)

  • zIndex - the z-index of the opened overlay - will be raised by 5 for each overlay
  • close(callHooks=true) - shortcut for overlay.close(options,callHooks) - options will be the same instance used for opening
  • Options
Name type default description
opacity Number 0.5 opacity of the overlay
dismissable Boolean true is the overlay dismissable by click or ESC?
onBeforeOpen Function null hook before open animation
onOpened Function null hook after open animation
onBeforeClose Function null hook before close animation
onClosed Function null hook after close animation
allowScroll Boolean false don't set overflow:hidden on body
color String "black" background-color of the overlay
zIndex Number 1000 minimum zIndex for the new overlay, cannot be lower than 1000

overlay.close(options=lastOverlay, callHooks=true)

  • options the options object which was used to open a overlay
  • callHooks set to false to suppress the calls of onBeforeClose and onClosed of that overlay

overlay.fade({el,opacity,cb})

overwrite to add a animation

  • el the div element of the overlay
  • opacity the target opacity of the opening/closing
  • cb a function which must be called when finished

vue-overlay is a singleton, so a fade function provided like this, will be used globally. Only do this once:

Velocity = require("velocity-animate")
Overlay = require("vue-overlay")
Overlay.obj.methods.fade = function ({el,opacity,cb}) {
  Velocity(el, {opacity: opacity}, {
    duration: 300,
    queue: false,
    easing: 'easeOutQuad',
    complete: cb
  })
}

Changelog

  • 2.0.0
    now compatible with vue 2.0.0

Development

Clone repository

npm install
npm run dev

Browse to http://localhost:8080/.

License

Copyright (c) 2016 Paul Pflugradt Licensed under the MIT license.

Related Packages

vuejs-loading-screen

Blocking screen while process worked

7,894 21
vue-loading-overlay

Vue.js component for full screen loading indicator.

2,880,068 1,261
vue3-loading-overlay

Vue.js component for full screen loading indicator, compatible for vue3.

156,113 13
@braid/griddle

A visual grid overlay and Sass mixin system to help with your front-end developm...

7,112 55
@basmilius/routing

Vue Router wrapper with overlay, modal and slide-over routing.

7,088 0

Version History

Version Released Vue License
2.0.0 ^2.0.1 MIT
1.0.1 ^1.0.26 MIT
1.0.0 ^1.0.21 MIT
0.1.1 ^1.0.21 MIT
0.1.0 ^1.0.21 MIT