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

refactor: stable scroll behavior #1094

Merged
merged 2 commits into from
May 22, 2024
Merged

refactor: stable scroll behavior #1094

merged 2 commits into from
May 22, 2024

Conversation

bang9
Copy link
Contributor

@bang9 bang9 commented May 17, 2024

Changes

  • Improvement of scroll position flickering when load previous messages
  • Attempt to load based on screen size threshold

test link

before: https://sendbird-uikit-react.netlify.app/
after: https://deploy-preview-1094--sendbird-uikit-react.netlify.app/

ticket: CLNP-3273

@bang9 bang9 self-assigned this May 17, 2024
Copy link

netlify bot commented May 17, 2024

Deploy Preview for sendbird-uikit-react ready!

Name Link
🔨 Latest commit bf1997b
🔍 Latest deploy log https://app.netlify.com/sites/sendbird-uikit-react/deploys/664d7ea5ac4d63000853afe4
😎 Deploy Preview https://deploy-preview-1094--sendbird-uikit-react.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 site configuration.

@bang9 bang9 force-pushed the fix/scroll-position branch 2 times, most recently from b827933 to 648fa7a Compare May 17, 2024 16:45
}
},
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to <InfiniteList />

scrollDistanceFromBottomRef.current = distanceFromBottom;
},
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to <InfiniteList />

Copy link
Collaborator

@HoonBaek HoonBaek left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -42,7 +46,11 @@ const pubSubFactory = <
publish: (topic, info) => {
if (topics[topic]) {
topics[topic].forEach((fn) => {
setTimeout(() => fn(info !== undefined ? info : {}), 0);
if (opts?.publishSynchronous) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of synchronous?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When publishing events, you can choose between synchronous and asynchronous execution.
Here are the differences illustrated with examples:

Synchronous Execution:

fns.forEach(fn => fn());
  • Blocking: Each function runs to completion before the next one starts, potentially causing delays if any function takes time.
  • Predictable Order: Functions execute in the exact order they are called.

Asynchronous Execution:

fns.forEach(fn => setTimeout(() => fn(), 0));
  • Non-blocking: Functions are scheduled to run after the current execution context, keeping the main thread free.
  • Less Predictable Order: Functions might not execute in the strict order they are scheduled due to other asynchronous tasks.

@bang9 bang9 merged commit e4e8bab into main May 22, 2024
8 checks passed
@bang9 bang9 deleted the fix/scroll-position branch May 27, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants