mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-27 12:03:52 +00:00
parent
b7e8b71097
commit
76f8c1bfdd
3 changed files with 18 additions and 4 deletions
|
|
@ -3,10 +3,10 @@ import { connect } from "react-redux";
|
|||
|
||||
import Balance from "../Balance";
|
||||
|
||||
const offsetFromBalance = balance => {
|
||||
export const offsetFromBalance = balance => {
|
||||
const percent = Math.abs(balance) / 100;
|
||||
const sprite = Math.round(percent * 28);
|
||||
const offset = (sprite - 1) * 15;
|
||||
const sprite = Math.floor(percent * 27);
|
||||
const offset = sprite * 15;
|
||||
return offset;
|
||||
};
|
||||
|
||||
|
|
|
|||
14
js/components/MainWindow/MainBalance.test.js
Normal file
14
js/components/MainWindow/MainBalance.test.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { offsetFromBalance } from "./MainBalance";
|
||||
|
||||
describe("offsetFromBalance", () => {
|
||||
it("works for positive numbers", () => {
|
||||
expect(offsetFromBalance(0)).toBe(0);
|
||||
expect(offsetFromBalance(50)).toBe(195);
|
||||
expect(offsetFromBalance(100)).toBe(405);
|
||||
});
|
||||
it("works for negative numbers", () => {
|
||||
expect(offsetFromBalance(-0)).toBe(0);
|
||||
expect(offsetFromBalance(-50)).toBe(195);
|
||||
expect(offsetFromBalance(-100)).toBe(405);
|
||||
});
|
||||
});
|
||||
|
|
@ -287,7 +287,7 @@ exports[`MainWindow renders to snapshot 1`] = `
|
|||
step="1"
|
||||
style={
|
||||
Object {
|
||||
"backgroundPosition": "0 --15px",
|
||||
"backgroundPosition": "0 -0px",
|
||||
}
|
||||
}
|
||||
title="Panning Bar"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue