Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4 - movement is now calculated with px values, not percent. Pixel boundaries (window height/width) are calculated by the
<App />parent component with an event listener for resize and passed as a prop to each<Dopefish />.Previously, movement speed was fine-tuned by modifying an
intervalvalue in each Dopefish component's state, where interval was the percentage to change position each tick (which was hardcoded at 50ms between ticks). Now, however, each tick is hardcoded to move 1px at a time and the interval - renamedtickIntervaldetermines the number of milliseconds between ticks. ModifyingtickIntervalwill modify movement speed. The default value is 20, for 20ms.Similarly, with the window height/width values available, position calculations are no longer percent based - each Dopefish component will now take a prop from the parent App container giving windowHeight and windowWidth (which will change if the window is resized, so it can handle resize events automatically) and use these to calculate current x/y position and target position. This could use some testing on high-DPI and low-DPI large monitors to fine-tune the interval in ms, but reducing from 50ms to 20ms is a good enough start.
Technically, this does mean the app will have very odd behavior in a window with dimensions equal to or smaller than 20x20px. 😄
Unlike percent-based coordinates, the component handles resize by allowing fish to potentially go off-screen to reach a target coordinate set. See #24 for details.