generated from finsweet/developer-starter
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restartWebflow: Added an awaitable promise as the return value
- Loading branch information
1 parent
b1f65e9
commit a8f242b
Showing
2 changed files
with
6 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
/** | ||
* Restart Webflow JS library | ||
* Restarts the Webflow JS library. | ||
* @returns An awaitable promise that is fulfilled when the library has been correctly reinitialized. | ||
*/ | ||
export const restartWebflow = (): void => { | ||
export const restartWebflow = async (): Promise<unknown> => { | ||
const { Webflow } = window; | ||
if (!Webflow || !('destroy' in Webflow) || !('ready' in Webflow) || !('require' in Webflow)) return; | ||
|
||
Webflow.destroy(); | ||
Webflow.ready(); | ||
Webflow.require('ix2')?.init(); | ||
|
||
return new Promise((resolve) => Webflow.push(() => resolve(undefined))); | ||
}; |