-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change floating molecule position from pixels to percentage
refactor: action buttons refactor: disable structure auto crop test: fix 'hide floating molecule' button selector test: fix 'Move floating molecule' button selector
- Loading branch information
1 parent
162946d
commit a778abc
Showing
7 changed files
with
155 additions
and
84 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
src/component/1d-2d/components/FloatMoleculeStructures/ActionsButton.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useChartData } from '../context/ChartContext.js'; | ||
|
||
function truncate(value, numberOfDigits = 0) { | ||
const power = 10 ** numberOfDigits; | ||
return Math.trunc(value * power) / power; | ||
} | ||
|
||
export function convertPixelToPercent(value: number, baseValue: number) { | ||
return truncate((value / baseValue) * 100, 3); | ||
} | ||
export function convertPercentToPixel(value: number, baseValue: number) { | ||
return Math.round((value / 100) * baseValue); | ||
} | ||
|
||
export function useSVGUnitConverter() { | ||
const { width, height } = useChartData(); | ||
|
||
function pixelToPercent(value: number, axis: 'x' | 'y') { | ||
const size = axis === 'x' ? width : height; | ||
return convertPixelToPercent(value, size); | ||
} | ||
function percentToPixel(value: number, axis: 'x' | 'y') { | ||
const size = axis === 'x' ? width : height; | ||
return convertPercentToPixel(value, size); | ||
} | ||
|
||
return { pixelToPercent, percentToPixel }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters