chanind / hanzi-writer

Chinese character stroke order animations and practice quizzes
https://hanziwriter.org
MIT License
3.47k stars 539 forks source link

How to dynamically change width/height of current HanziWriter? #244

Closed peterolson closed 3 years ago

peterolson commented 3 years ago

Once I've already created a writer with HanziWriter.create, is there any way to change the width and height dynamically?

I'm setting the size of the writer based on the size of the window, but this breaks when the window is resized after the writer is created.

chanind commented 3 years ago

There's not an easy way to do that currently, aside from doing something fancy with an SVG G element, or just deleting and recreating the HanziWriter element. I think it should be doable though to add an updateDimensions() method that will recreate the image elements in the new size while keeping the state the same. The user-drawn stroke path might be a bit weird, but maybe it will just work. I'll work on a PR...

chanind commented 3 years ago

:tada: This issue has been resolved in version 3.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

peterolson commented 3 years ago

Awesome, works like a charm!