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: Optional virtualize, imageUrlFn #369

Merged
merged 14 commits into from
Mar 26, 2021
Merged

Conversation

agiangrant
Copy link
Contributor

Description

New props:
imageUrlFn - Allows the fetching of each emoji image URL
virtualize - experimental scrolling for emojis to avoid loading all 3000 emojis in one load.

Motivation and Context

The main motivation for this change was responsiveness when opening the emoji picker around complex components. ngx-emoji-mart works very well in the standalone github page, but when loaded into an app that consumes a fair amount of system resources, the initialization and rendering times of all the emojis were not acceptable. The option to show a single category is better but affects the end-user experience. To mitigate this, virtual scrolling was implemented per category (this could be enhanced to be per row of emojis). Instead of fetching the whole sprite sheet, I've also allowed the option to fetch individual emojis. This is more convenient for those loading a few emojis in view (whether from browser cache or some type of CDN). The use case would be the end-user who uses 10 of the 3000 emojis. Used with the new virtualize prop, it will reduce the amount data getting loaded into ngx-emoji-mart.

How has this been tested?

This has been tested thoroughly on my local machine. Virtualization is completely optional and experimental, so it will need to improved at some point. For now, this will cover basic use cases.

Screenshots (if appropriate):

Looks the same as what exists in master today

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link

@acostajohn acostajohn left a comment

Choose a reason for hiding this comment

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

This would be of great help 🙏

src/lib/picker/category.component.ts Outdated Show resolved Hide resolved
@agiangrant
Copy link
Contributor Author

@scttcper let me know if you need anything from me to get this merged in

@agiangrant agiangrant removed the request for review from urish March 17, 2021 21:18
@agiangrant
Copy link
Contributor Author

I'll be adding an optional parameter to allow virtualized offset height virtualizeOffset.

@agiangrant
Copy link
Contributor Author

I have pushed changes to customize virtual scrolling visibility. README is updated. default is 0. Use a higher, positive integer to increase the number of emojis to render at a time. Use a lower, negative integer to decrease the number of emojis to render at a time.

@agiangrant
Copy link
Contributor Author

@scttcper All set! Let me know if you find anything else. It's looking smooth on my end. When I find some time I'll look into rendering emojis by row.

@scttcper scttcper changed the title Optional virtualize, imageUrlFn feat: Optional virtualize, imageUrlFn Mar 26, 2021
@scttcper scttcper merged commit 2fbbfea into scttcper:master Mar 26, 2021
@scttcper
Copy link
Owner

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@acostajohn
Copy link

Hey guys, I think something else changed because now the performance is increidibly better without using virtualize 😂

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.

4 participants