Skip to content

Conversation

@Gondragos
Copy link
Contributor

Refactored Frames.tsx and Minimap.tsx to use the newly added useResizeObserver hook for timely width calculations. Added memoized references and hooks to have relevant callbacks. Introduced a new debounced useResizeObserver hook in the core library.

Before:

video_resize.mov
timeline_resize.mov
playing_zoom.mov

Refactored `Frames.tsx` and `Minimap.tsx` to use the newly added `useResizeObserver` hook for timely width calculations. Added memoized references and hooks to have relevant callbacks. Introduced a new debounced `useResizeObserver` hook in the core library.
@Gondragos Gondragos requested review from a team, hlomzik and nick-skriabin as code owners July 24, 2025 14:17
@netlify
Copy link

netlify bot commented Jul 24, 2025

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit e23fb62
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/6886ba3dc185cf00085fd0c0

@netlify
Copy link

netlify bot commented Jul 24, 2025

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit e23fb62
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/6886ba3dd8f24d000845a44f
😎 Deploy Preview https://deploy-preview-8038--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Jul 24, 2025

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit e23fb62
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/6886ba3d7dc05100073f457d

@github-actions github-actions bot added the fix label Jul 24, 2025
@netlify
Copy link

netlify bot commented Jul 24, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit e23fb62
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/6886ba3da102280008dc8807
😎 Deploy Preview https://deploy-preview-8038--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@yyassi-heartex yyassi-heartex left a comment

Choose a reason for hiding this comment

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

About time we got a hook for resize observer! great work!

@Gondragos
Copy link
Contributor Author

Gondragos commented Jul 24, 2025

/git merge

Workflow run
Successfully merged: 1 file changed, 1 insertion(+), 1 deletion(-)

@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

❌ Patch coverage is 83.56164% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.88%. Comparing base (2a5bef8) to head (e23fb62).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
web/libs/core/src/hooks/useResizeObserver.ts 79.66% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8038      +/-   ##
===========================================
- Coverage    70.21%   65.88%   -4.33%     
===========================================
  Files          715      505     -210     
  Lines        50325    33493   -16832     
  Branches      8600     8621      +21     
===========================================
- Hits         35334    22068   -13266     
+ Misses       14988    11422    -3566     
  Partials         3        3              
Flag Coverage Δ
lsf-e2e 59.48% <71.23%> (-0.02%) ⬇️
lsf-integration 55.63% <83.56%> (+0.01%) ⬆️
lsf-unit 9.40% <0.00%> (+0.01%) ⬆️
pytests ?

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.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

entries: ResizeObserverEntry[],
): T => {
if (entries.length === 0) return {} as T;
const { width, height } = elements[0].getBoundingClientRect();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why methods are different for 1 and for many? could you add a link to MDN or another resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With one element we get in entries exactly the element I expect to get, and it already has the right sizes.
With more than one element it provides only entries that exactly had changes. So it's harder to get the first element size if there is no guarantee that the first entry will be related to the first element.

}
};
const handleAnimationFrameRef = useRef(handleAnimationFrame);
handleAnimationFrameRef.current = handleAnimationFrame;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks so confusing... are there other ways to have recursion in functional components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Recursion works fine. It just can't use the right values inside the function without moving them to ref if they are changing during execution.
It's the same trick as when we move handlers from props to ref to decrease the necessity to invalidate caches of useMemo/useCallback.

Sergei Koshevarov and others added 2 commits July 26, 2025 04:32
@niklub niklub merged commit 2a8a341 into develop Jul 28, 2025
45 of 46 checks passed
@robot-ci-heartex robot-ci-heartex deleted the fb-BROS-220/video-onresize branch July 28, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants