Skip to content

Commit

Permalink
fix(graphics context setting): opacity = 1 when args.opacity is zero …
Browse files Browse the repository at this point in the history
…(falsy value) (#134)

* opacity is no longer 1 when explicitly set to 0
  • Loading branch information
L2jLiga committed Aug 18, 2020
1 parent 669c262 commit 926d230
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion models/GraphicsContextSettings/GraphicsContextSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GraphicsContextSettings {
} else {
Object.assign(this, GraphicsContextSettings.Model, args, {
blendMode: blendModeMap[args.blendMode || 'normal'],
opacity: args.opacity || 1,
opacity: Number.isFinite(args.opacity) ? args.opacity : 1,
});
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ describe('GraphicsContextSettings', () => {
const graphicsContextSettings = new GraphicsContextSettings(null, json);
expect(JSON.stringify(json, null, 2)).toEqual(JSON.stringify(graphicsContextSettings, null, 2));
});

it('should correctly handle opacity = 0', () => {
const graphicsContextSettings = new GraphicsContextSettings({
opacity: 0,
});

expect(graphicsContextSettings.opacity).toBe(0);
});
});

0 comments on commit 926d230

Please sign in to comment.