lentschi / ngx-ellipsis

Multiline text with ellipsis for angular 9+
MIT License
96 stars 22 forks source link

Provide a way to find out if text overflows and ellipsis presence #39

Closed padu closed 4 years ago

padu commented 4 years ago

Implementing ngx-ellipsis, we came across a requirement to show tooltip on mouse over only when ellipsis are not present or text overflow.

Right now we don't have any way which pragmatically indicate the status of ellipsis presence.

There are multiple ways we can provide this access.

  1. Make isOverflowing method public so that user can access element overflow state using ViewChildren or ViewChild in angular component.
  2. Provide output event emitter that will update flag state to outer component.
ArenMaghakyan commented 4 years ago

@padu As solution I compare rendered text with original to decide whether tooltip should be visible or not. Hope this will help. e.g. #spanElement [ngbTooltip]="spanElement.innerText === name ? '' : name"

padu commented 4 years ago

@padu As solution I compare rendered text with original to decide whether tooltip should be visible or not. Hope this will help. e.g. #spanElement [ngbTooltip]="spanElement.innerText === name ? '' : name"

@ArenMaghakyan above solution works perfectly well. Thanks for a quick turnaround.

lentschi commented 4 years ago

@padu @ArenMaghakyan

Provide output event emitter that will update flag state to outer component.

That part of your request already exists (has been in there for a long time) - see the README on the ellipsis-change Output. I've created a Stackblitz - is this what you need?: https://stackblitz.com/edit/ngx-ellipsis-change?file=src%2Fapp%2Fapp.component.html

padu commented 4 years ago

@padu @ArenMaghakyan

Provide output event emitter that will update flag state to outer component.

That part of your request already exists (has been in there for a long time) - see the README on the ellipsis-change Output. I've created a Stackblitz - is this what you need?: https://stackblitz.com/edit/ngx-ellipsis-change?file=src%2Fapp%2Fapp.component.html

Better way of doing, This is exactly expected.