0.10.0 • Published 9 years ago
rxcss v0.10.0
RxCSS
RxCSS is a very small library for manipulating CSS Custom Properties (aka CSS Variables) with RxJS Observables.
More Info
- :book: Read the slides: http://slides.com/davidkhourshid/reactanim#/
- :movie_camera: Watch the presentation: https://www.youtube.com/watch?v=lTCukb6Zn3g
Requirements
Make sure RxJS is installed and globally available.
Installation
You can either use RxCSS in an existing project:
npm install rxcss@latest --saveOr you can include it directly in a <script> tag:
<script src="https://unpkg.com/@reactivex/rxjs/dist/global/Rx.min.js"></script>
<script src="https://unpkg.com/rxcss@latest/dist/rxcss.min.js"></script>Usage
const mouse$ = Rx.Observable
.fromEvent(document, 'mousemove')
.map(({ clientX, clientY }) => ({
x: clientX,
y: clientY
}));
const style$ = RxCSS({
mouse: mouse$,
});
// Optional
style$.subscribe(...);:root {
--mouse-x: 0;
--mouse-y: 0;
}
.ball {
transform:
translateX(calc(var(--mouse-x) * 1px))
translateY(calc(var(--mouse-y) * 1px));
}API
RxCSS(observableMap[, target])
Sets each key/value pair, where each value is an observable, as a CSS variable on the target.
observableMap(Object) - an object where each:keyis the CSS variable name to be set on thetargetvalueis either an Observable stream of values, or a single value to set the CSS variable to.
target(Element) - the DOM node to set the CSS variables to. Default:document.documentElement.
0.10.0
9 years ago
0.9.0
9 years ago
0.8.0
9 years ago
0.7.1
9 years ago
0.7.0
9 years ago
0.6.0
9 years ago
0.5.0
9 years ago
0.4.1
9 years ago
0.4.0
9 years ago
0.3.1
9 years ago
0.3.0
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.0
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago