Package Exports
- svelte-modal
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (svelte-modal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
svelte-modal
A vanilla JS basic popup modal made with Svelte. Use this as the base component for making nice, useful modals, like svelte-dialog.
install
$ npm install svelte-modal
TODO
- Stop depending on a fork of svelta-extras
- This README is missing a lot of stuff. For now, just look at the demo code and the component source code.
example
import Modal from 'svelte-modal'
const content = document.createElement('p')
content.textContent = 'Modal content.'
const modal = new Modal({
center: false, // false => aligned to top, true => aligned to center
zIndexBase: 1, // adjust the relative z-index of the modal
transitionDuration: 225, // duration of transition in and out
pressScrimToDismiss: true, // press outside the modal to dismiss it
escapeToDismiss: true, // press escape key to dismiss the modal
slots: { default: content }
})
modal.on('result', result => {
result // result of either modal.close or modal.dismiss
})
modal.on('closed', result => {
result // result that was passed to `modal.close`
})
modal.on('dismissed', result => {
result // result that was passed to `modal.dismissed`
})
modal.on('hidden', () => {}) // fires when the modal has finished transitioning out
modal.open()
modal.close('foo')
// or
modal.dismiss('bar')