r/angularjs • u/InterwebCountyPress • Dec 11 '13
Angular would be great for super-responsive layouts except it doesn't work in IE
Edit: Solved! Thanks Evereal!
Here it is being used on site I'm working on (ignore the sluggish masonry, I'm working on it).
Look! Responsive images:
http://i.embed.ly/1/display/crop?height={{(1000 * window_width/ 2 * retina) | decimal}}&width={{(1000 * window_width* retina) | decimal}}&url={{topstory.image}}&key=jlakjflakjflakjfal;kja;lkja;lkjalkj('retina' = 2 if it's a retina display, 1 if it's not)
Pretty neat, huh? You can get a perfect layout on any screen right down to the last pixel. EXCEPT IT DOESN'T WORK IN IE.
I guess I'm hoping someone has a solution to the IE bug, because to me this is so much cooler than css media queries. I'm considering telling IE users to just fuck off.
2
Upvotes
8
u/evereal Dec 11 '13 edited Dec 11 '13
Hang on, the only thing IE doesn't like is templates within regular style attributes (not ngStyle).
If you replace your:
style="width: {{(1000 * window_width) | decimal}}px; font-size: {{(40 * window_width) | decimal}}px;"with:
ng-style="{width: ((1000 * window_width) | decimal), 'font-size': ((40 * window_width) | decimal)}"It works fine in IE. Use ngStyle, not regular style attributes when you want to get fancy and dynamic with styles! That's what it was made for!
However, I still wouldn't recommend it in this case. Frequent digest cycles (like when someone is resizing your app) can have a significant performance impact once your app is non-trivial. It's not a "couple of calculations, big deal" as you put it.