diff options
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/utils.ts | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index d05541ca9..d9007dd77 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -148,41 +148,6 @@ function scrollToTop () { | |||
148 | window.scroll(0, 0) | 148 | window.scroll(0, 0) |
149 | } | 149 | } |
150 | 150 | ||
151 | // Thanks: https://github.com/uupaa/dynamic-import-polyfill | ||
152 | function importModule (path: string) { | ||
153 | return new Promise((resolve, reject) => { | ||
154 | const vector = '$importModule$' + Math.random().toString(32).slice(2) | ||
155 | const script = document.createElement('script') | ||
156 | |||
157 | const destructor = () => { | ||
158 | delete window[ vector ] | ||
159 | script.onerror = null | ||
160 | script.onload = null | ||
161 | script.remove() | ||
162 | URL.revokeObjectURL(script.src) | ||
163 | script.src = '' | ||
164 | } | ||
165 | |||
166 | script.defer = true | ||
167 | script.type = 'module' | ||
168 | |||
169 | script.onerror = () => { | ||
170 | reject(new Error(`Failed to import: ${path}`)) | ||
171 | destructor() | ||
172 | } | ||
173 | script.onload = () => { | ||
174 | resolve(window[ vector ]) | ||
175 | destructor() | ||
176 | } | ||
177 | const absURL = (environment.apiUrl || window.location.origin) + path | ||
178 | const loader = `import * as m from "${absURL}"; window.${vector} = m;` // export Module | ||
179 | const blob = new Blob([ loader ], { type: 'text/javascript' }) | ||
180 | script.src = URL.createObjectURL(blob) | ||
181 | |||
182 | document.head.appendChild(script) | ||
183 | }) | ||
184 | } | ||
185 | |||
186 | function isInViewport (el: HTMLElement) { | 151 | function isInViewport (el: HTMLElement) { |
187 | const bounding = el.getBoundingClientRect() | 152 | const bounding = el.getBoundingClientRect() |
188 | return ( | 153 | return ( |
@@ -216,7 +181,6 @@ export { | |||
216 | getAbsoluteEmbedUrl, | 181 | getAbsoluteEmbedUrl, |
217 | objectLineFeedToHtml, | 182 | objectLineFeedToHtml, |
218 | removeElementFromArray, | 183 | removeElementFromArray, |
219 | importModule, | ||
220 | scrollToTop, | 184 | scrollToTop, |
221 | isInViewport, | 185 | isInViewport, |
222 | isXPercentInViewport | 186 | isXPercentInViewport |