From 4db5ac324bb0f667fc289b0480250c7d1053154b Mon Sep 17 00:00:00 2001 From: amiceli Date: Tue, 14 Jul 2020 17:47:27 +0200 Subject: [PATCH] Add default export for initializeShareon. It allows to initialize share button after window.load, for example on SPA dynamic element. --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4634160..e0825ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,7 +44,7 @@ function initShareonChild(child: HTMLElement, preset: PublishPreset) { } } -window.onload = () => { +const initializeShareon = () : void => { const shareonContainers = document.getElementsByClassName('shareon'); for (let i = 0; i < shareonContainers.length; i += 1) { @@ -70,3 +70,7 @@ window.onload = () => { } } }; + +window.onload = () => { initializeShareon(); }; + +export default initializeShareon;