Skip to content

Commit

Permalink
Update gradient.class.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Aug 24, 2022
1 parent a5c48f5 commit 378ab72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gradient/gradient.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Gradient<S, T extends GradientType = S extends GradientType ? S : '
transform = this.gradientTransform ? this.gradientTransform.concat() : iMatrix.concat(),
gradientUnits = this.gradientUnits === 'pixels' ? 'userSpaceOnUse' : 'objectBoundingBox';
// colorStops must be sorted ascending
let colorStops = this.colorStops.sort((a, b) => {
const colorStops = this.colorStops.concat().sort((a, b) => {
return a.offset - b.offset;
});

Expand Down Expand Up @@ -202,7 +202,7 @@ export class Gradient<S, T extends GradientType = S extends GradientType ? S : '
);
if (needsSwap) {
// svg goes from internal to external radius. if radius are inverted, swap color stops.
colorStops = colorStops.reverse();
colorStops.reverse(); // mutates array
colorStops.forEach(colorStop => {
colorStop.offset = 1 - colorStop.offset;
});
Expand Down

0 comments on commit 378ab72

Please sign in to comment.