MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / updateDomWithContent

Function updateDomWithContent

js/main.js:156–180  ·  view source on GitHub ↗

* Update the dom with the specified content * @param {Module} module The module that needs an update. * @param {number} [speed] The (optional) number of milliseconds for the animation. * @param {string} newHeader The new header that is generated. * @param {HTMLElement} newContent The new content

(module, speed, newHeader, newContent, animateOut, animateIn, createAnimatedDom = false)

Source from the content-addressed store, hash-verified

154 * @returns {Promise<void>} Resolved after the module DOM update is applied or hide/show transition is scheduled.
155 */
156async function updateDomWithContent (module, speed, newHeader, newContent, animateOut, animateIn, createAnimatedDom = false) {
157 if (module.hidden || !speed) {
158 updateModuleContent(module, newHeader, newContent);
159 return;
160 }
161
162 if (!moduleNeedsUpdate(module, newHeader, newContent)) {
163 return;
164 }
165
166 if (createAnimatedDom && animateIn !== null) {
167 Log.debug(`${module.identifier} createAnimatedDom (${animateIn})`);
168 updateModuleContent(module, newHeader, newContent);
169 if (!module.hidden) {
170 _showModule(module, speed, null, { animate: animateIn });
171 }
172 return;
173 }
174
175 await new Promise((resolve) => _hideModule(module, speed / 2, resolve, { animate: animateOut }));
176 updateModuleContent(module, newHeader, newContent);
177 if (!module.hidden) {
178 await new Promise((resolve) => _showModule(module, speed / 2, resolve, { animate: animateIn }));
179 }
180}
181
182/**
183 * Check if the content has changed.

Callers 1

_updateDomFunction · 0.85

Calls 4

updateModuleContentFunction · 0.85
moduleNeedsUpdateFunction · 0.85
_showModuleFunction · 0.85
_hideModuleFunction · 0.85

Tested by

no test coverage detected