Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a simple overlay

NotificationsYou must be signed in to change notification settings

vue-comps/vue-overlay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-overlay

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

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.0npm install --save-dev vue-overlay@1

or includebuild/bundle.js.

Usage

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

For examples seedev/.If you need to reliable get theVue instance, seevue-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 foroverlay.close(options,callHooks) - options will be the same instance used for opening
  • Options
Nametypedefaultdescription
opacityNumber0.5opacity of the overlay
dismissableBooleantrueis the overlay dismissable by click or ESC?
onBeforeOpenFunctionnullhook before open animation
onOpenedFunctionnullhook after open animation
onBeforeCloseFunctionnullhook before close animation
onClosedFunctionnullhook after close animation
allowScrollBooleanfalsedon't setoverflow:hidden on body
colorString"black"background-color of the overlay
zIndexNumber1000minimum 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 tofalse to suppress the calls ofonBeforeClose andonClosed of that overlay

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

overwrite to add a animation

  • el thediv 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 installnpm run dev

Browse tohttp://localhost:8080/.

License

Copyright (c) 2016 Paul PflugradtLicensed under the MIT license.

About

a simple overlay

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp