IMPR: Events handling

This commit is contained in:
Tony Air 2021-02-24 16:40:59 +07:00
parent 3ee3c9850f
commit d025910921
1 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,8 @@
/* /*
* Lightbox window * Lightbox window
*/ */
import Events from './_events';
import { Component } from 'react'; import { Component } from 'react';
import styles from '../scss/_window.scss'; import styles from '../scss/_window.scss';
@ -109,6 +111,8 @@ class MetaWindow extends Component {
} }
ui.state.collections[gallery][i].click(); ui.state.collections[gallery][i].click();
W.dispatchEvent(new Event('MetaLightboxUI.next'));
}; };
prev = () => { prev = () => {
@ -124,6 +128,8 @@ class MetaWindow extends Component {
} }
ui.state.collections[gallery][i].click(); ui.state.collections[gallery][i].click();
W.dispatchEvent(new Event('MetaLightboxUI.prev'));
}; };
reset = () => { reset = () => {
@ -214,6 +220,8 @@ class MetaWindow extends Component {
); );
break; break;
} }
W.dispatchEvent(new Event('MetaLightboxUI.loaded'));
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
@ -239,6 +247,8 @@ class MetaWindow extends Component {
} }
ui.setState({ error: msg }); ui.setState({ error: msg });
W.dispatchEvent(new Event('MetaLightboxUI.error'));
}) })
.then(() => { .then(() => {
ui.setState({ loading: false }); ui.setState({ loading: false });
@ -281,6 +291,7 @@ class MetaWindow extends Component {
console.log(`${ui.name}: show`); console.log(`${ui.name}: show`);
ui.setState({ shown: true }); ui.setState({ shown: true });
W.dispatchEvent(new Event('MetaLightboxUI.show'));
}; };
hide = () => { hide = () => {
@ -288,6 +299,7 @@ class MetaWindow extends Component {
console.log(`${ui.name}: hide`); console.log(`${ui.name}: hide`);
ui.setState({ shown: false }); ui.setState({ shown: false });
W.dispatchEvent(new Event('MetaLightboxUI.hide'));
}; };
getHtml = () => { getHtml = () => {