Skip to content

Commit

Permalink
[docs] Replace double tildes with Math.trunc in tutorials (#6880)
Browse files Browse the repository at this point in the history
Using double tildes for truncating fractional numbers isn't readable for people who haven't encountered it before
  • Loading branch information
gtm-nayan authored Oct 25, 2021
1 parent b2d23e9 commit 990c21f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
return `
transform: scale(${eased}) rotate(${eased * 1080}deg);
color: hsl(
${~~(t * 360)},
${Math.trunc(t * 360)},
${Math.min(100, 1000 - 1000 * t)}%,
${Math.min(50, 500 - 500 * t)}%
);`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ We can get a lot more creative though. Let's make something truly gratuitous:
return `
transform: scale(${eased}) rotate(${eased * 1080}deg);
color: hsl(
${~~(t * 360)},
${Math.trunc(t * 360)},
${Math.min(100, 1000 - 1000 * t)}%,
${Math.min(50, 500 - 500 * t)}%
);`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
return {
duration,
tick: t => {
const i = ~~(text.length * t);
const i = Math.trunc(text.length * t);
node.textContent = text.slice(0, i);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function typewriter(node, { speed = 1 }) {
return {
duration,
tick: t => {
const i = ~~(text.length * t);
const i = Math.trunc(text.length * t);
node.textContent = text.slice(0, i);
}
};
Expand Down

0 comments on commit 990c21f

Please sign in to comment.