[docs] Replace double tildes with Math.trunc in tutorials (#6880)

Using double tildes for truncating fractional numbers isn't readable for people who haven't encountered it before
pull/6881/head
Nayan Gautam 3 years ago committed by GitHub
parent b2d23e9d11
commit 990c21f7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,7 @@
return ` return `
transform: scale(${eased}) rotate(${eased * 1080}deg); transform: scale(${eased}) rotate(${eased * 1080}deg);
color: hsl( color: hsl(
${~~(t * 360)}, ${Math.trunc(t * 360)},
${Math.min(100, 1000 - 1000 * t)}%, ${Math.min(100, 1000 - 1000 * t)}%,
${Math.min(50, 500 - 500 * t)}% ${Math.min(50, 500 - 500 * t)}%
);` );`

@ -59,7 +59,7 @@ We can get a lot more creative though. Let's make something truly gratuitous:
return ` return `
transform: scale(${eased}) rotate(${eased * 1080}deg); transform: scale(${eased}) rotate(${eased * 1080}deg);
color: hsl( color: hsl(
${~~(t * 360)}, ${Math.trunc(t * 360)},
${Math.min(100, 1000 - 1000 * t)}%, ${Math.min(100, 1000 - 1000 * t)}%,
${Math.min(50, 500 - 500 * t)}% ${Math.min(50, 500 - 500 * t)}%
);` );`

@ -17,7 +17,7 @@
return { return {
duration, duration,
tick: t => { tick: t => {
const i = ~~(text.length * t); const i = Math.trunc(text.length * t);
node.textContent = text.slice(0, i); node.textContent = text.slice(0, i);
} }
}; };

@ -21,7 +21,7 @@ function typewriter(node, { speed = 1 }) {
return { return {
duration, duration,
tick: t => { tick: t => {
const i = ~~(text.length * t); const i = Math.trunc(text.length * t);
node.textContent = text.slice(0, i); node.textContent = text.slice(0, i);
} }
}; };

Loading…
Cancel
Save