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
Add support for non-scaling-stroke vector effect. #234
Conversation
…t index.html file
Thanks @alexgurr for your PR! The code seems great, I need to test it as well with few examples tho. Otherwise excellent PR, you've updated the tests as well. I try to get back to you once I have few examples. (my bank holiday weekend is a bit chaotic but I'll try to be fast) |
Thanks for the kind words. No rush, I'm currently using a GitHub path in my package json file! Test it thoroughly! I thought about a manual svg test but seemed to be overly complex (the test index.html file didn't even render any SVGs). |
Ok, after few tests I remember why I didn't implemented this back in the days. It's very tough (if not impossible) to provide an correct value of the path length after transformation. Because the calculation will be based on the scale (width and height) of the element. For example: I did a little test case : http://maxwellito.github.io/drafts/vivus-issue-234/ The robust solution would be to calculate every path length manually and not via |
I would suggest that a solution that partially works (seems to fix 80% of your examples) is potentially better than nothing? It also looks to me that the scale calculation works for landscape but not portrait. I wonder if there's a third condition/calculation we need for working out scale in the use case height is larger than width? |
Definitely, I would make it clear in the docs that the feature is not 100% reliable but should fit most cases. I was investigating to use width and height (cf draft) but still not perfect. I was also looking is the Pythagorean theorem, but still looking :) Also, this make me think that, when Vivus is parsing a SVG with |
I can try and help with some further stuff here if you can provide me that debug HTML and how to run it? My biggest issue was I couldn't run any of the manual examples. |
Hey @alexgurr So, after a lot of tests cases I reached this conclusion: while scaling for a line length, it's fine to go bigger than smaller. It might make the line appearing super fast in the worst case scenario, but won't start/stop right in the middle (and look terribly clunky). To do so, I take the biggest scale between X-axis and Y-axis, because it will cover the extreme cases. I updated my draft : diff and demo About the re-mapping, I'm happy to ask users to make a call to Tell me what you think :) |
Yeah looks good to me. I think that's a reasonable compromise for a consistently working solution. I think we can should add a section in the documentation about non-scaling-stroke and any caveats. We can then add a sub-section about resizing, maybe explaining the use of mapping, draw and reset and an observer, maybe with a code example? There are multiple ways people could handle resizing. Again, as I mentioned above, I simply override the inline stroke styles with 0 and Feel free to close this PR and merge your PR/code in (the automated test is probably still relevant, although the value might need tweaking based on your new scale calculation. Probably also need a few tests to cover different SVG aspect ratios). I like your demo - I'd like to see it added to the repo as well. Nice work :) (On a side note, drawer is a mis-spell [means something different] and should simply be draw. Not sure how you'd change it now and stay backwards compatible. Maybe rename it, then add a |
Hehe, I know how bad this codebase is about spelling mistakes. My english has slightly improved since. But I never thought this little library would get so much attention. I'll make some changes, feel free to add more :) About the inline style, I'd like to leave it to I have only one concern, its about leaving the responsibility to the user to set up an observer when the SVG has
About your PR, let's keep it, if you don't mind I would like to make PRs to your branch (or code suggestions) so we can keep the conversation here. I'll add examples in the manual tests as well. |
The I see what you're saying. I guess it's as simple as do we take the time to build the observer logic or do we offload that to the user? I think it's also based on what the user of the library wants? For example for me, I'd rather just finish the animation immediately if the window is resized, rather than try and dynamically try and change the stroke offset mid-animation (I think the experience would be better). My only concern with the observer approach is that it's natively throttled. This means (in theory), as the window is resized there will be slight delays in the calculation and change of stroke offset. This will mean there's always weird gaps (briefly) as the resizing occurs. Observation resizers are also one way of doing this. Potentially we could make some recommendations/examples but let the user decide? tl;dr I think the warning approach and some good documentation/examples in the README (a 'kill' animation approach and a window observer approach) is the best way to let the user decide how they want to tackle it. |
Let's do this. I'm starting the implementation now. Sorry about the delay in my responses, there are big changes in my personal and professional life. It's tough to find some spare time :-D |
Ok, I have most of it : code change, readme update, new manual test. However, I still have an issue with the Observer. I will have a closer look later |
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
Co-authored-by: Alex Gurr <thegurrkin@hotmail.co.uk>
This reverts commit a2f1f06.
This reverts commit 0c35655.
Ok this is good to go now. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to go!
@alexgurr thank you very much for your patience and going thru it with me. I wish everybody in the OSS world would take time, as you did, to implement features that matter to them. Big kudos to you
Thanks for your time too :). It'll make an appearance in my package react-simple-line-chart when I get round to finishing it! |
Hey!
I've added new scaling support for path lengths and included a test with two different kinds of path (identical other than this attribute).
Fixes #112
Would love someone to test a bunch of SVGs manually to prove this, but I've tested with my own line graph and it works.