LeaVerou / prefixfree

Break free from CSS prefix hell!
http://projects.verou.me/prefixfree/
MIT License
3.82k stars 713 forks source link

resize trigger on prefixfree.viewport-units #194

Closed konsumer closed 10 years ago

konsumer commented 10 years ago

I'd like to be able to do window.onresize = function(){ prefixfree.updateViewPortSizing() } so viewport units work responsively. Not sure where to reach into the plugin. Any suggestions? Should I just make it an option of the plugin, and add it directly?

LeaVerou commented 10 years ago

The problem is that they are replaced with px when PF parses the CSS, otherwise they'd be dropped from it and you'd have to keep refetching it. Perhaps you could change the way PF works and store the original CSS somewhere in a property of the <style> or <link> element and reprocess it when the window is resized. Not sure if you'd want to make such extensive changes though. This can't be solved with a few tweaks I'm afraid.

konsumer commented 10 years ago

Yep, I checked how it works. I think it could be solved by tracking the changes instead of just doing a simple replace (like the way translation works.) Considering this, I will look to change how it works rather than hook into it. Thanks!

zeorin commented 9 years ago

I've fixed this issue in the following PR: https://github.com/LeaVerou/prefixfree/pull/215.

Instead of simply rewriting the declaration, my function appends the px version of the declaration behind the viewport unit declaration. The regex has been adjusted to match the resulting double declaration also, so on resize (which I added an event listener for), it can read the original declaration and then overwrite only the appended bit.