(
runtimeScene: gdjs.RuntimeScene,
yesOrNo: boolean
)
| 123 | }; |
| 124 | |
| 125 | export const displayLoader = ( |
| 126 | runtimeScene: gdjs.RuntimeScene, |
| 127 | yesOrNo: boolean |
| 128 | ) => { |
| 129 | const domElementContainer = getDomElementContainer(runtimeScene); |
| 130 | if (!domElementContainer) { |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | if (yesOrNo) { |
| 135 | const loaderContainer: HTMLDivElement = document.createElement('div'); |
| 136 | loaderContainer.id = loaderContainerId; |
| 137 | loaderContainer.style.backgroundColor = '#000000'; |
| 138 | loaderContainer.style.display = 'flex'; |
| 139 | loaderContainer.style.height = '100%'; |
| 140 | loaderContainer.style.width = '100%'; |
| 141 | loaderContainer.style.justifyContent = 'center'; |
| 142 | loaderContainer.style.alignItems = 'center'; |
| 143 | loaderContainer.style.position = 'relative'; |
| 144 | loaderContainer.style.zIndex = '2'; |
| 145 | const loader = document.createElement('img'); |
| 146 | loader.setAttribute('width', '50px'); |
| 147 | loader.setAttribute( |
| 148 | 'src', |
| 149 | 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CjxjaXJjbGUgb3BhY2l0eT0nMC4yNScgY3g9IjEyIiBjeT0iMTIiIHI9IjEwIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iNCI+PC9jaXJjbGU+CjxwYXRoIG9wYWNpdHk9JzAuNzUnIGZpbGw9IiNGRkZGRkYiIGQ9Ik00IDEyYTggOCAwIDAxOC04VjBDNS4zNzMgMCAwIDUuMzczIDAgMTJoNHptMiA1LjI5MUE3Ljk2MiA3Ljk2MiAwIDAxNCAxMkgwYzAgMy4wNDIgMS4xMzUgNS44MjQgMyA3LjkzOGwzLTIuNjQ3eiI+PC9wYXRoPgo8L3N2Zz4=' |
| 150 | ); |
| 151 | try { |
| 152 | loader.animate( |
| 153 | [{ transform: 'rotate(0deg)' }, { transform: 'rotate(359deg)' }], |
| 154 | { |
| 155 | duration: 3000, |
| 156 | iterations: Infinity, |
| 157 | } |
| 158 | ); |
| 159 | } catch { |
| 160 | logger.warn('Animation not supported, loader will be fixed.'); |
| 161 | } |
| 162 | loaderContainer.appendChild(loader); |
| 163 | if ( |
| 164 | domElementContainer.children && |
| 165 | domElementContainer.children.length > 0 |
| 166 | ) { |
| 167 | domElementContainer.insertBefore( |
| 168 | loaderContainer, |
| 169 | domElementContainer.children[0] |
| 170 | ); |
| 171 | } else { |
| 172 | domElementContainer.appendChild(loaderContainer); |
| 173 | } |
| 174 | } else { |
| 175 | const loaderContainer = domElementContainer.querySelector( |
| 176 | `#${loaderContainerId}` |
| 177 | ); |
| 178 | if (!loaderContainer) return; |
| 179 | try { |
| 180 | domElementContainer.removeChild(loaderContainer); |
| 181 | } catch {} |
| 182 | } |
nothing calls this directly
no test coverage detected