Html object tag for svg find width

I have


Where content is a svg.

Currently i am trying to figure this on elm.

        [ Attr.attribute "data" "${content}"
        , Attr.type_ "image/svg+xml"

QUESTION: how can i find the width of the svg?

I tried in elm on "load" but it does not fire. Javascript or elm solution welcomed, but i prefer elm

I tried on elm

on "change" decodeImgLoad


on "load" decodeImgLoad

but they do not get called at all.

When i used img instead of object it worked, but i want to have the svg set up correctly on the dom and not just as image.

In elm i can not reference the svg directly, i need img or object or to convert it into elm svg. (to convert it into elm svg is not possible, as the svg is large)

I created an ellie to test and the load event appears to fire:

If the decoder fails:

onLoad : msg -> Attribute msg
onLoad msg =
    on "load" <| "fail"

you get no msg - so you might look at the decoder, this decoder will succeed:

onLoad : msg -> Attribute msg
onLoad msg =
    on "load" <| Decode.succeed msg

I will try later, thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.