Skip to content

Commit

Permalink
Use native mod function for variables
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanchuan committed Mar 31, 2024
1 parent 5a423a4 commit c3ed230
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/function.js
Expand Up @@ -79,6 +79,9 @@ function calc_with(base) {
let op = v[0];
let { unit = '', value } = parse_compound_value(v.substr(1).trim() || 0);
if (/^var/.test(base)) {
if (op === '%') {
return `calc(mod(${base}, ${value}) * 1${unit})`;
}
return `calc((${base} ${op} ${value}) * 1${unit})`;
}
return compute(op, base, value) + unit;
Expand All @@ -87,6 +90,9 @@ function calc_with(base) {
let op = v.substr(-1);
let { unit = '', value } = parse_compound_value(v.substr(0, v.length - 1).trim() || 0);
if (/^var/.test(base)) {
if (op === '%') {
return `calc(mod(${value}, ${base}) * 1${unit})`;
}
return `calc((${value} ${op} ${base}) * 1${unit})`;
}
return compute(op, value, base) + unit;
Expand Down

0 comments on commit c3ed230

Please sign in to comment.