Active-CSS / active-css

The epic event-driven browser language for UI with functionality in one-liner CSS. Over 100 incredible CSS commands for DOM manipulation, ajax, reactive variables, single-page application routing, and lots more. Could CSS be the JavaScript framework of the future?
https://activecss.org
Other
42 stars 7 forks source link

Set up a boolean auto-reversing observe event. #279

Closed bob2517 closed 6 months ago

bob2517 commented 1 year ago

Set up an observe event that handles opposite reactions without the need for a reverse observe event.

The event will only allow boolean-type actions, like add-class, remove-class, set-attribute/remove-attribute, etc.

Commands like ajax, render, etc. would not be allowed in the event, solely because we don't know what the opposite would be, and adding syntax for coping with that would result in a more complicated solution to simply writing the reverse observe event.

A lot of scenarios could work with this - adding and removing classes for triggering and resetting animations is just one example, which is a staple in modern websites.

bob2517 commented 1 year ago

Real-world example using an existing observe event:

man:if-not-in-house:observe {
  set-attribute: data-shoes "";
}

The opposite event when using a regular observe event:

man:if-in-house:observe {
  remove-attribute: data-shoes;
}

In the new syntax, this would be reduced to:

man:if-in-house:boolean-observe {
  remove-attribute: data-shoes;
}

"boolean-observe" is a working name for the event - it probably won't be this.

bob2517 commented 6 months ago

Closing for now. Need a practical use case to warrant this.