ncstate-sat / popover

Popover component for Angular
MIT License
225 stars 47 forks source link

Feature: support alternative forms of building a popover #23

Open willshowell opened 7 years ago

willshowell commented 7 years ago
rosslavery commented 6 years ago

This is a big one for me. We have a large list of items, each with multiple popover triggers (think a table).

It would be nice to be able to use event delegation to register a single listener on the parent, and then open the popover with a service and position it based on the event.target for the captured click.

willshowell commented 6 years ago

It would be easiest (for now) to just support passing a popover instance to not have to duplicate the Input bindings in the service api. Are you thinking something like this would work?

@ViewChild('editPopover') editPopover;
@ViewChild('deletePopover') deletePopover;

openEditPopoverAt(targetEl) {
  this.satPopoverService.open(this.editPopover, {anchor: targetEl});
}

For your use case, is there any value difference in passing a popover instance vs. template ref vs. component class?

rosslavery commented 6 years ago

My original motivation for wanting this was to keep the DOM as light as possible. So rather than having 4 sat-popover components per-row, each with their own click listeners, I would have 4 "dumb" icons in the DOM, then register a single listener on the parent.

Because of this, I suppose my ideal use-case would avoid needing to have the sat-popver in the DOM at all, and instead open the popover by just passing in a component class (similar to how MdDialog works.)

Edit: I understand these are just pie-in-the-sky discussions, and my ideas aren't necessarily simple to implement.

willshowell commented 6 years ago

Ahh I see. AFAIK a popover's content won't pollute the DOM until it's opened, but I understand not wanting 100s or 1000s of popover instances hanging around in memory until they're needed.

So effectively like MatDialog but with the ability to anchor to an element? It would return some popover ref that you could use to close it or whatever.

And out of curiosity, for this use case, would you need more than one popover open at a time?

rosslavery commented 6 years ago

Yeah exactly. And you're right about the popover content not polluting. I'm just developing for some fairly performance constrained devices so every little bit counts ☺️

On Nov 18, 2017 3:48 PM, "Will Howell" notifications@github.com wrote:

Ahh I see. AFAIK a popover's content won't pollute the DOM until it's opened, but I understand not wanting 100s or 1000s of popover instances hanging around in memory until they're needed.

So effectively like MatDialog but with the ability to anchor to an element? It would return some popover ref that you could use to close it or whatever.

And out of curiosity, for this use case, would you need more than one popover open at a time?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ncstate-sat/popover/issues/23#issuecomment-345470165, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoF9PMHJ8L3GAOw-U1KAuJapdmsnSi7ks5s30KogaJpZM4Pc43G .