visibility.mjs 490 B

12345678910111213141516
  1. const invisibleValues = new Set(["none", "hidden"]);
  2. /**
  3. * Returns a function that, when provided a progress value between 0 and 1,
  4. * will return the "none" or "hidden" string only when the progress is that of
  5. * the origin or target.
  6. */
  7. function mixVisibility(origin, target) {
  8. if (invisibleValues.has(origin)) {
  9. return (p) => (p <= 0 ? origin : target);
  10. }
  11. else {
  12. return (p) => (p >= 1 ? target : origin);
  13. }
  14. }
  15. export { invisibleValues, mixVisibility };