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

Config show more as a prop, use component's width to show/hide show more button #769

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Dananji
Copy link
Collaborator

@Dananji Dananji commented Feb 6, 2025

Related issue: #762

The calculation for truncating longer annotation texts uses a temporary Canvas object to calculate average character width based on font, fontSize, and clientWidth of the annotation text HTML div element for the given annotation text.
Using this average character width, the code calculates the maximum number of characters the div can display without exceeding the textLineLimit value given in the props.

This feature can be turned ON/OFF by using the value of showMoreSettings: { enableShowMore: false, textLineLimit: 6 } prop passed into MarkersDisplay component at the time of initialization.

Maximum number of characters to show for truncation of the text is calculated as follows to account the discrepancies around the spaces at of line breaks within text display;

const maxCharactersToShow = charsPerLine * (MAX_LINES - 1) +  Math.floor(charsPerLine / 2);

With this calculation the display text line length doesn't exceed the given value to the prop textLineLimit when the component is initialized.

longer text in annotation

With the fixes around the calculations for the multi line shorter texts in an Annotation the texts are displayed as follows;

multiple texts in annotation

@Dananji Dananji marked this pull request as draft February 7, 2025 14:20
@Dananji Dananji marked this pull request as ready for review February 7, 2025 20:15
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.

1 participant