androidsvg icon indicating copy to clipboard operation
androidsvg copied to clipboard

Feature request: interactivity

Open Coyamo opened this issue 6 years ago • 14 comments

Can this excellent library expose more methods, such as converting svg to Android's path object, if possible, I hope you can add some functions to implement click events for different images in svg.😁

Coyamo avatar Oct 06 '19 16:10 Coyamo

I saw similar questions in the past, but I still hope to expose some ways to implement the click function. (Or I didn't find it?😞) I am sorry to bother you!

Coyamo avatar Oct 06 '19 17:10 Coyamo

Hi Coyamo.

When you say "converting svg to Android's path object", what do you mean exactly? What would be the input and output? I know other libraries have things like parsePath(), which take an SVG path description and return a Path. Is that what you mean? Or something else?

implement click events

I am working on a new version of SVGImageView. I want it to be able to support taps and other events.

Paul

BigBadaboom avatar Oct 07 '19 02:10 BigBadaboom

'converting svg to Android's path object' is just to get a Path object to implement the click event (check if the clicked coordinates are in the path). If you are implementing a click event, I don't think I need to get the path😳. Thank you for your reply, I am looking forward to your new version!

Coyamo avatar Oct 07 '19 06:10 Coyamo

For example, I might be able to getPath from the SVG object ,SVG.getFromX.getPath() ...

Coyamo avatar Oct 07 '19 07:10 Coyamo

Okay. Thanks. I will rename this issue to reflect your request.

BigBadaboom avatar Oct 07 '19 07:10 BigBadaboom

Hey @BigBadaboom. I'm researching your project for a corporate use case.

I would need to be able to break down an SVG into separate components that can be individually clickable. I think this is what @Coyamo is also asking?

Or if this is already possible somehow using your library, I'd love to learn how.

In your sample app, it looks like the rubics cube is doing this... setting individual colors.

Please advise.

DeutschDaniel avatar Dec 10 '19 19:12 DeutschDaniel

@DeutschDaniel Interactivity is not supported at the moment. But I intend for it to be in the next release.

BigBadaboom avatar Dec 11 '19 12:12 BigBadaboom

Hi Paul, how do you intend to provide this feature ? Which strategy are you plan to use ? Any plan for this release ?

Maybe we could provide some help, even if for test/debug/dev

Thanks for you work, Marco

Hi all

A new SVGView class that supports zoom and pan is basically complete. Next step is to add interactivity to it.

Dear reader. If you are waiting for this feature, it would be helpful if I had an idea of what level of API support each of you would need, or prefer.

  1. Simple global click listener SVG.registerClickHandler(fn). Where fn gets called with the clicked element's id
  2. Simple click listeners attachable to any SVG graphics element by Id. Eg. SVG.registerClickHandler(id, fn)
  3. Full DOM style: querySelector[All](sel).addEventListener("click", fn)
  4. Support event bubbling. Ie. the ability to attach event listeners to container elements, such as groups.
  5. Support event capture phase. Ie. addEventListener("click", fn, true).
  6. Support pointer-events CSS property
  7. Support getIntersectionList(), getEnclosureList(), checkIntersection(), and checkEnclosure().

Please reply with your list, sorted by preference. For example: 2, 3, 1.

Thanks! Paul

BigBadaboom avatar Mar 05 '20 12:03 BigBadaboom

1,2,7 Personally, these should meet the my needs. Thank you for your efforts

Coyamo avatar Mar 06 '20 11:03 Coyamo

Yeah 1, 2 would be perfect. 6, 7 could also work.

i-mitra avatar Sep 11 '20 05:09 i-mitra

Hi @BigBadaboom 1,2,6 and 7 would be really great to have features. Thanks

Viraj7009 avatar Oct 02 '20 11:10 Viraj7009

Hey @BigBadaboom, I've implemented a bit of this for my application on my fork. I would love to give back to this library, therefore I was wondering, if there is anyway we could review the code change, so all of us could benefit.

i-mitra avatar Jul 18 '21 08:07 i-mitra

Hi Ishan

I've implemented a bit of this for my application on my fork. I would love to give back to this library, therefore I was wondering, if there is anyway we could review the code change, so all of us could benefit.

You could create a pull request if you like. Or summarise your changes in a document and create a bug (or email it to me).

Thanks Paul

BigBadaboom avatar Jul 18 '21 10:07 BigBadaboom