Skip to content

Done with the problem faced of loosing screen. #2491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 11, 2024

Conversation

perminder-17
Copy link
Contributor

@perminder-17 perminder-17 commented Oct 4, 2023

Fixes #2483

Changes: I have make the preview screen where we cannot loose it. Please check the video.

p5.js.Web.Editor.5.mp4

I have done my best to change it.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@perminder-17
Copy link
Contributor Author

U may check @lindapaiste whenever u are free.

Copy link
Collaborator

@lindapaiste lindapaiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're combining two approaches here. You are setting a maxSize state but not ever using it. Instead you're setting the maxSize of the SplitPane directly from the window.innerWidth.

The code that you have here will actually work, but in a way that is very roundabout. Resizing the window calls the resize event handler, which calls setMaxSize. That changes the state of the component and forces a re-render, so the props of the SplitPane will get re-evaluated using the current value of window.innerWidth.

To keep the code cleaner I recommend the following changes:

  1. Remove window.innerWidth as a dependency of the useEffect. You only need to add the resize event listener once. The dependencies should be [] or [setMaxSize] (both will only evaluate the effect once). If that is confusing, consider that the handler could be written as const updateInnerWidth = (e) => { setMaxSize(e.target.innerWidth); };.
  2. Assign the state to a variable maxSize and use this to control the SplitPane : maxSize={maxSize * 0.965}.
  3. As I'm writing this, I realize the issue of having an undefined value the first render and now I suspect that you probably wrote it the way that you did to avoid getting an NaN value from multiplication with undefined. How about we set the initial value of the state from the window? const [maxSize, setMaxSize] = useState(window.innerWidth);

@perminder-17
Copy link
Contributor Author

I sincerely apologize for the delay @lindapaiste . Upon reevaluating my approach, I have recognized the shortcomings and made the necessary adjustments as per your guidance. Thanks for your suggestion.

Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I'm going to merge this in as it seems to resolve the issue for now. Please feel free to add any further comments or changes before the next release around next Tuesday, January 16.

@raclim raclim merged commit d956b05 into processing:develop Jan 11, 2024
@perminder-17
Copy link
Contributor Author

Thanks for the merge @raclim and I will definetly add any further changes before 16th of Jan. Really thanks for considering me. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit Horizontal Scrolling of Output Page to Prevent Loss at Screen Edge
3 participants