Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8fd218c74 | |||
| 5f652530ed | |||
| 11b927b91f | |||
| e1a426bde4 |
@@ -37,21 +37,6 @@
|
|||||||
<p id="eventfilter-status" class="visually-hidden" aria-live="polite"></p>
|
<p id="eventfilter-status" class="visually-hidden" aria-live="polite"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
|
||||||
.event-filter-target-list {
|
|
||||||
view-transition-name: event-filter-list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
|
||||||
::view-transition-group(event-filter-list),
|
|
||||||
::view-transition-old(event-filter-list),
|
|
||||||
::view-transition-new(event-filter-list) {
|
|
||||||
animation-duration: 240ms;
|
|
||||||
animation-timing-function: ease;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const filters = document.getElementById('eventfilters');
|
const filters = document.getElementById('eventfilters');
|
||||||
|
|
||||||
@@ -129,34 +114,9 @@
|
|||||||
const stateStorageKey = 'event-filter-state';
|
const stateStorageKey = 'event-filter-state';
|
||||||
const stateQueryKey = 'event_filter';
|
const stateQueryKey = 'event_filter';
|
||||||
|
|
||||||
const animationMs = 220;
|
|
||||||
let hideTimers = new WeakMap();
|
|
||||||
const supportsViewTransitions = typeof document.startViewTransition === 'function';
|
|
||||||
let isViewTransitionMutation = false;
|
|
||||||
let currentFilter = { type: 'all', value: '' };
|
let currentFilter = { type: 'all', value: '' };
|
||||||
let suppressedChangeEvents = 0;
|
let suppressedChangeEvents = 0;
|
||||||
|
|
||||||
const runWithLayoutTransition = (mutation) => {
|
|
||||||
if (!supportsViewTransitions) {
|
|
||||||
mutation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
document.startViewTransition(() => {
|
|
||||||
isViewTransitionMutation = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
mutation();
|
|
||||||
} finally {
|
|
||||||
isViewTransitionMutation = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
mutation();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const hasOptionValue = (selectElement, value) => {
|
const hasOptionValue = (selectElement, value) => {
|
||||||
if (!selectElement) {
|
if (!selectElement) {
|
||||||
return false;
|
return false;
|
||||||
@@ -280,50 +240,12 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearHideTimer = (eventItem) => {
|
|
||||||
const timer = hideTimers.get(eventItem);
|
|
||||||
|
|
||||||
if (timer) {
|
|
||||||
window.clearTimeout(timer);
|
|
||||||
hideTimers.delete(eventItem);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const showEvent = (eventItem) => {
|
const showEvent = (eventItem) => {
|
||||||
clearHideTimer(eventItem);
|
|
||||||
|
|
||||||
if (eventItem.hidden) {
|
|
||||||
if (supportsViewTransitions && !isViewTransitionMutation) {
|
|
||||||
runWithLayoutTransition(() => {
|
|
||||||
eventItem.hidden = false;
|
eventItem.hidden = false;
|
||||||
});
|
|
||||||
} else {
|
|
||||||
eventItem.hidden = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
eventItem.classList.remove('is-filtered-out');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const hideEvent = (eventItem) => {
|
const hideEvent = (eventItem) => {
|
||||||
clearHideTimer(eventItem);
|
|
||||||
eventItem.classList.add('is-filtered-out');
|
|
||||||
|
|
||||||
const timer = window.setTimeout(() => {
|
|
||||||
if (supportsViewTransitions && !isViewTransitionMutation) {
|
|
||||||
runWithLayoutTransition(() => {
|
|
||||||
eventItem.hidden = true;
|
eventItem.hidden = true;
|
||||||
});
|
|
||||||
} else {
|
|
||||||
eventItem.hidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
hideTimers.delete(eventItem);
|
|
||||||
}, animationMs);
|
|
||||||
|
|
||||||
hideTimers.set(eventItem, timer);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setActiveControl = ({ type, value }) => {
|
const setActiveControl = ({ type, value }) => {
|
||||||
@@ -411,7 +333,6 @@
|
|||||||
currentFilter = filterState;
|
currentFilter = filterState;
|
||||||
setActiveControl(filterState);
|
setActiveControl(filterState);
|
||||||
|
|
||||||
runWithLayoutTransition(() => {
|
|
||||||
events.forEach((eventItem) => {
|
events.forEach((eventItem) => {
|
||||||
if (matches(eventItem, filterState)) {
|
if (matches(eventItem, filterState)) {
|
||||||
showEvent(eventItem);
|
showEvent(eventItem);
|
||||||
@@ -419,7 +340,6 @@
|
|||||||
hideEvent(eventItem);
|
hideEvent(eventItem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
updateStatus(filterState);
|
updateStatus(filterState);
|
||||||
syncState(filterState);
|
syncState(filterState);
|
||||||
|
|||||||
Reference in New Issue
Block a user