Use standard form buttons and resume entrance effects in 1.10.1
This commit is contained in:
1 parent
f182f9e125
commit
cff468167b
12 files changed
+161
-12
No files matched your search
+13
-4
@@ -26,10 +26,19 @@ export function initMotion(doc = document) {
|
||||
const observer = new view.IntersectionObserver(entries => {
|
||||
for (const entry of entries) if (entry.isIntersecting) { show(entry.target); observer.unobserve(entry.target); }
|
||||
}, { threshold: 0, rootMargin: '0px 0px -24px 0px' });
|
||||
if (!preference.matches) nodes.forEach(node => observer.observe(node));
|
||||
const reduce = () => { if (preference.matches) { observer.disconnect(); animations.forEach(animation => animation.cancel()); } };
|
||||
preference.addEventListener('change', reduce);
|
||||
return () => { observer.disconnect(); animations.forEach(animation => animation.cancel()); preference.removeEventListener('change', reduce); };
|
||||
const syncPreference = () => {
|
||||
if (preference.matches) {
|
||||
observer.disconnect();
|
||||
animations.forEach(animation => animation.cancel());
|
||||
} else {
|
||||
// Reduction may have been active at startup or enabled during this visit.
|
||||
// Resume observing unseen content when movement is allowed again.
|
||||
nodes.forEach(node => { if (!seen.has(node)) observer.observe(node); });
|
||||
}
|
||||
};
|
||||
preference.addEventListener('change', syncPreference);
|
||||
syncPreference();
|
||||
return () => { observer.disconnect(); animations.forEach(animation => animation.cancel()); preference.removeEventListener('change', syncPreference); };
|
||||
}
|
||||
|
||||
if (!document.querySelector('#editor')) initMotion();
|
||||
Reference in new issue
Block a user