Skip to content

Commit 9708005

Browse files
committed
Add @ts and @TS
1 parent d8f5d2b commit 9708005

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

src/function.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,14 @@ const Expose = add_alias({
563563
return calc_with(`var(--${utime.name})`);
564564
},
565565

566+
ts() {
567+
return calc_with(`calc(var(--${utime.name}) / 1000)`);
568+
},
569+
570+
TS() {
571+
return calc_with(`calc(var(--${UTime.name}) / 1000)`);
572+
},
573+
566574
UT() {
567575
return calc_with(`var(--${UTime.name})`);
568576
},

src/generator/css.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ class Rules {
250250

251251
check_uniforms(name) {
252252
switch (name) {
253-
case 'ut': case 'UT': case 't': case 'T': this.uniforms.time = true; break;
253+
case 'ut': case 'UT': case 't': case 'T': case 'ts': case 'TS':
254+
this.uniforms.time = true; break;
254255
case 'ux': this.uniforms.mousex = true; break;
255256
case 'uy': this.uniforms.mousey = true; break;
256257
case 'uw': this.uniforms.width = true; break;
@@ -794,19 +795,21 @@ class Rules {
794795
}
795796

796797
if (this.uniforms.time) {
798+
let n = 'animation-name';
799+
let t = utime.ticks;
800+
let un = utime.name;
801+
let Un = UTime.name;
797802
this.styles.container += `
798803
:host,.host {
799804
animation:${utime.animation()},${UTime.animation(DELAY + 'ms')};
800805
}
801806
`;
802807
this.styles.keyframes += `
803-
@keyframes ${utime['animation-name']} {
804-
from {--${utime.name}:0}
805-
to {--${utime.name}:${Math.trunc(utime.ticks/(1000/60))}}
808+
@keyframes ${utime[n]} {
809+
from {--${un}:0} to {--${un}:${t}}
806810
}
807-
@keyframes ${UTime['animation-name']} {
808-
from {--${UTime.name}:0}
809-
to {--${UTime.name}:${utime.ticks}}
811+
@keyframes ${UTime[n]} {
812+
from {--${Un}:0} to {--${Un}:${t}}
810813
}
811814
`;
812815
}

src/uniforms.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
function create_time_uniform(name) {
22
let ticks = 1000 * 60 * 60 * 24; /* 24 hours in ms */
3+
let steps = ticks / (1000 / 60);
34
let aname = `${name}-animation`;
45
return {
56
name, ticks,
67
'animation-name': aname,
7-
animation: (delay='0s') => `${ticks}ms linear ${delay} infinite ${aname}`
8+
animation: (delay='0s') => `${ticks}ms steps(${steps}) ${delay} infinite ${aname}`
89
}
910
}
1011

0 commit comments

Comments
 (0)