Skip to content
tsybenko edited this page Jan 9, 2020 · 3 revisions

Hooks - are the methods of Modal instance which are synchronous and will invoke function that passed as argument.


Declared hooks

# Name Description Cancelable
1. beforeOpen Before open -
2 onOpen After "beforeOpen" +
3. opened Opened -
4. beforeClose Before close -
5 onClose After "beforeClose" +
6. closed Closed -

Examples

const mw = new Modal(el, options)
mw.beforeOpen(function(event) {
  console.log(event);
});

const consoleLogger = function(event) {
  console.log(event);
};

const mw = new Modal(el, options)
mw.beforeOpen(consoleLogger);
mw.onOpen(function(event) {
  event.preventDefault();
  consoleLogger(event)
});
// Will not be opened because "onOpen" prevented this action
mw.opened(consoleLogger);
Clone this wiki locally