Skip to content

Commit 7861b27

Browse files
committed
dom-flash
1 parent 6b17e65 commit 7861b27

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

demo/main.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,17 @@ const renderOutputs = () => {
158158
reactRoot.render(React.createElement(React.Fragment, null, reactNode));
159159
};
160160

161+
for (const el of [reactPreviewEl, quillHtmlPreviewEl, semanticHtmlPreviewEl]) {
162+
new MutationObserver((mutations) => {
163+
for (const m of mutations) {
164+
const parent = m.target.parentElement;
165+
if (!parent) continue;
166+
parent.style.animation = 'none';
167+
void parent.offsetWidth;
168+
parent.style.animation = '';
169+
}
170+
}).observe(el, { characterData: true, subtree: true });
171+
}
172+
161173
quill.on('text-change', renderOutputs);
162174
renderOutputs();

demo/styles.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,12 @@ pre {
150150
#editor {
151151
min-height: 240px;
152152
}
153+
154+
@keyframes dom-flash {
155+
from { background-color: rgba(250, 204, 21, 0.3); }
156+
to { background-color: transparent; }
157+
}
158+
159+
.preview-shell * {
160+
animation: dom-flash 0.6s ease-out;
161+
}

0 commit comments

Comments
 (0)