Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svg enhancement #5

Open
Neon22 opened this issue Feb 25, 2024 · 0 comments
Open

svg enhancement #5

Neon22 opened this issue Feb 25, 2024 · 0 comments

Comments

@Neon22
Copy link

Neon22 commented Feb 25, 2024

I was trying to change the width of an svg rect I'd made.:
Made it like:

SVG.rect(x=self.draft_handle.parent.start[0], y=self.draft_handle.parent.start[1],
      width=width, height=height,
      style=style, id="baserect")

Its all good and onscreen. Then I attempt to resize it using:
ltk.find("#baserect").attr("width", width)

But no go for reasons below.

However it can be done by using the regular dom:
ltk.window.document.querySelector("#baserect").setAttribute('width', width)

Jquery has uneven support for SVG. (There is an svg extension for jquery though which make some overrides. Not sure if its in Jquery 3 by default).
I note that when attempting to modify (say) the width of an svg rectangle (using its id), you get:
an object of type = SVGAnimatedLength with roughly this structure:

baseVal: {
    unitType: number,
    value: number,
    valueInSpecifiedUnits: number,
    valueAsString: number
},
animVal: { /* etc */ }

Clearly using this could be good because we could animate with it.
I'm not sure if ALL browsers return the same thing but can the ltk take advantage if it does ??

Halfway down this page is some discussion on this class and Jquery3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant