Похожие чаты

Here'S a fun demo for bringing reactive programming into CSS

- use JS to teach your styles to respond to streams of data by setting a CSS variable. Here we can feed in the window dimensions and cursor position to make the background color of the website change in realtime:

<style>
:root {
--window-width: "innerWidth";
--window-height: "innerHeight";
--cursor-x: "clientX";
--cursor-y: "clientY";
background: hsl(
/* cursor from left-to-right edge goes between 0<->360 */
calc((var(--cursor-x) / var(--window-width)) * 360),
/* cursor from bottom-to-top goes between 0<->100% */
calc(100% - (var(--cursor-y) / var(--window-height) * 100%)),
calc(100% - (var(--cursor-y) / var(--window-height) * 100%))
);
}
</style>

<script type=module>
import computedVariables from 'https://unpkg.com/computed-variables/index.es.js'

// set --cursor- variables to cursor position
computedVariables(
'--cursor-',
(value, event) => event.touches ? e.touches[0][value] : event[value],
window,
['mousemove', 'touchmove']
)

// set --window- variables to window properties
computedVariables(
'--window-',
value => window[value]
)
</script>

3 ответов

6 просмотров

It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.

Did i tell you that you're awesome today? I should've

awesome

Похожие вопросы

Обсуждают сегодня

Типа вызывать GetParent и проверять на соответствие GetModuleHandle?
The Bird of Hermes
67
Do any of you guys have interesting projects one could join? I'm a Middle Full-Stack developer (JS/TS, React & Node)
Lev Shapiro
39
$res = json_decode($наша строка из респонса); $res1 = array_map(fn($o) => $o->name, $res->breadcrumbs[0]->entities); Как такое будет на Хаскеле?.. В начале весь джейсон, в ко...
Хаскель Моисеевич Гопник
24
Hello, I have a question. Can anyone help me? I want to make my cryptocurrencies, like Tron, untraceable by anyone, even government organizations. I was told that to do this,...
 ➛ Eᒪᕼᗩᗰ
14
I read yesterday that in the near future most cryptos will be gone. It's like there is a lot of bullshit within the crypto sphere and this corruption some way is going to be c...
Kanah The Great
25
В чем сила брат, в NASM или FASM?
Isaac Kleiner
18
Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
10
Хтось використовував Vapor на Windows?
Jaroshevskii
15
Hi Everybody I bought BCH when it’s 600 and I’m new in crypto what should I do ?
Khush
12
Тут кста кто-нибудь NeoVim использует?
Simple Sorcerer
13
Карта сайта