html - Click behavior changes on SVG when changing between<img> and <object> -


i have 4 svg buttons part of main menu on personal webpage.

enter image description here

/----------------------------------------------------------------------------------------------------------------------------------/

when 1 clicked, 4 buttons retract corners , respective section revealed (i.e. aboutme button --> aboutme section). enter image description here

originally had svg objects embedded in img tag so:

<img class = "button active" id = "person-icon" src = "resources/main-page-icons/person-icon.svg"/> 

i did because read when there no need animate svg isn't necessary embed in object/embed tag. however, decided today wanted create hover effect svg element. had change img tag object allow styling/animating

<object class = "button active" id = "person-icon" data = "resources/main-page-icons/person-icon.svg" type = "image/svg+xml"></object> 

the hover effect works expected, but can't click it. inspecting element reveals i'm clicking on svg itself , not object it's embedded in. wrapping in div did not solve problem either.

question: there way can animate svg element while handling click events on object element it's embedded in?

in case asks "why not handle click event within svg element?" don't think it's possible or make sense svg element's behavior influence other elements why handled click events outside of svg element (i.e. click 1 button --> other buttons expand, content faded in = bad). maybe can, didn't think made sense , wasn't necessary initially.

thanks in advance.

i found answer here after time googling:

this kind of tag needs content show on page.

your tag:

<object data="images/logo.svg" type="image/svg+xml" class="icon-logo"></object>

is not having inner html-content, won't able click it.

this has object requiring sort of innerhtml in order recognized dom. if added text <object>zoot!</object> click it. additionally, svg dom differs fundamentally html dom , lacks innerhtml. more on here.

the work around use image tag , surround in div can animate/style on. works part, in case div circle (border-radius: 50%) , when translated across screen skews shape. looks goofy when background/border applied , skewing visible. that's post though!


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -