I'm not quite sure of the syntax, but I'm taking a comma separated list of properties $properties and want to join them by a comma, so (background-color, color) becomes background-color .5s, color .5s
@mixin transition($properties, $duration) {
$props: ();
@each $prop in $properties {
$tmp: $prop unquote($duration);
$props: append($props, $tmp);
}
$str: join($props, ',');
-moz-transition: $str, -moz-transform $duration;
-webkit-transition: $str, -webkit-transform $duration;
-o-transition: $str, -o-transform $duration;
transition: $str, transform $duration;
}
What I'm actually getting is this:
border-color 0.5s background-color 0.5s ",", -moz-transform 0.5s
when it should be:
border-color 0.5s, background-color 0.5s, -moz-transform 0.5s
You're overcomplicating this just a little bit by using 2 operations for joining (append and join):
@mixin transition($properties, $duration) {
$props: ();
$duration: unquote($duration);
@each $p in $properties {
$props: append($props, $p $duration, comma);
}
-moz-transition: $props, -moz-transform $duration;
-webkit-transition: $props, -webkit-transform $duration;
-o-transition: $props, -o-transform $duration;
transition: $props, transform $duration;
}
.foo {
@include transition((background-color, color), '.5s');
}
Output:
.foo {
-moz-transition: background-color .5s, color .5s, -moz-transform .5s;
-webkit-transition: background-color .5s, color .5s, -webkit-transform .5s;
-o-transition: background-color .5s, color .5s, -o-transform .5s;
transition: background-color .5s, color .5s, transform .5s;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With