-
Notifications
You must be signed in to change notification settings - Fork 391
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
Feature: Automatic rerendering on resize #272
Closed
kplindegaard
wants to merge
26
commits into
bernii:gh-pages
from
kplindegaard:feature/rerender_on_rescale
Closed
Feature: Automatic rerendering on resize #272
kplindegaard
wants to merge
26
commits into
bernii:gh-pages
from
kplindegaard:feature/rerender_on_rescale
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work in progress
Introduction
It is somewhat inconvenient that the gauge/donut does not adapt to the element it is included in. Therefore it is not straight-forward to use gauge.js in responsive pages. Even though #64 tries to deal with this upon creation, we would like it to happen dynamically as well. Also, some of the later improvements make a bit harder to find the best scaling approach.
This PR is an attempt to support automatic rescaling and rerendering as the page or parent element changes size. It uses the
ResizeObserver
pattern that was introduced around 2021 and is supported by all browsers. If used in older, deprecated browsers whereResizeObserver
is not available, resizing will not be possible.Details
This PR potentially introduces breaking changes.
Using
ResizeObserver
, the code will automatically attach a handler for resizing events at creation of bothGauge
andDonut
objects and should thus work for both. In order for it to work properly, be aware of:<canvas>
element MUST be assigned a uniqueid
. For example `.detachAll()
method on each gauge/donut object.Regarding point 2 above:
More details coming later. For now note: