This commit is contained in:
Matteo Manzinello 2020-04-25 14:15:03 +02:00
parent da99e2d262
commit cbbdc7fb6e
2 changed files with 7 additions and 3 deletions

View File

@ -1,3 +1,5 @@
// import mailgo
import mailgo from "../mailgo";
// call init mailgo attached to the event DOMContentLoaded
mailgo({ initEvent: "DOMContentLoaded" });

View File

@ -822,15 +822,15 @@ const mailgoStyle = () => {
document.head.appendChild(mailgoCSS);
};
// export default for mailgo
export default (mailgoConfig?: any) => {
// mailgo
const mailgo = (mailgoConfig?: any) => {
// if the window is defined...
if (window && typeof window !== "undefined") {
// add the style for mailgo
mailgoStyle();
// if is set an initEvent add the listener
if (mailgoConfig.initEvent) {
if (mailgoConfig?.initEvent) {
document.addEventListener(mailgoConfig.initEvent, mailgoInit);
} else {
mailgoInit();
@ -840,3 +840,5 @@ export default (mailgoConfig?: any) => {
document.addEventListener("click", mailgoCheckRender);
}
};
export default mailgo;