Skip to content
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

feat(component): helper function observeResize to observe size change via global ResizeObserver #7241

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

CatsJuice
Copy link
Member

@CatsJuice CatsJuice commented Jun 18, 2024

import { observeResize } from "@affine/component";


useEffect(() => {
  const dispose = observeResize(element entry => {
    console.log(entry.contentRect);
  });

  return () => dispose();
}, []);

Copy link

graphite-app bot commented Jun 18, 2024

Your org has enabled the Graphite merge queue for merging into canary

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Member Author

CatsJuice commented Jun 18, 2024

Copy link

nx-cloud bot commented Jun 18, 2024

@CatsJuice CatsJuice requested review from EYHN and pengx17 June 18, 2024 03:48
@CatsJuice CatsJuice marked this pull request as ready for review June 18, 2024 03:48
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 21.42857% with 22 lines in your changes missing coverage. Please review.

Project coverage is 59.47%. Comparing base (be36e03) to head (98e3538).

Files Patch % Lines
...ges/frontend/component/src/utils/observe-resize.ts 22.22% 21 Missing ⚠️
.../component/src/ui/date-picker/week-date-picker.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary    #7241      +/-   ##
==========================================
- Coverage   59.49%   59.47%   -0.03%     
==========================================
  Files         847      848       +1     
  Lines       37922    37945      +23     
  Branches     3957     3964       +7     
==========================================
+ Hits        22561    22567       +6     
- Misses      15066    15083      +17     
  Partials      295      295              
Flag Coverage Δ
server-test 78.50% <ø> (ø)
unittest 28.53% <21.42%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@pengx17 pengx17 left a comment

Choose a reason for hiding this comment

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

Thanks! TIL it is better to use single instance of ResizeObserver
WICG/resize-observer#59

@CatsJuice CatsJuice requested a review from pengx17 June 18, 2024 04:45
@CatsJuice CatsJuice changed the title feat(component): new useResizeObserver hook to reuse instance globally feat(component): helper function observeResize to observe size change via global ResizeObserver Jun 18, 2024
Copy link

graphite-app bot commented Jun 18, 2024

Merge activity

… via global ResizeObserver (#7241)

```ts
import { observeResize } from "@affine/component";

useEffect(() => {
  const dispose = observeResize(element entry => {
    console.log(entry.contentRect);
  });

  return () => dispose();
}, []);
```
@Brooooooklyn Brooooooklyn force-pushed the catsjuice/feat/use-resize-observer branch from 4738da5 to 98e3538 Compare June 19, 2024 09:05
@graphite-app graphite-app bot merged commit 98e3538 into canary Jun 19, 2024
32 checks passed
@graphite-app graphite-app bot deleted the catsjuice/feat/use-resize-observer branch June 19, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants