ミックスインやファンクションに変身したいと思っていますが、私はそれを構築する方法を頭で覆すことができません。どこでも検索されましたが、私はパズルを組み立てることができません。高度なSCSS/SASSミックスイン/ファンクション
出力はこの
{
opacity: 0;
transform: translateY(3em);
@keyframes moveUp {
from {
opacity: 0;
transform: translateY(3em);
} to {
opacity: 1;
transform: translateY(0);
}
}
.inview ~ & {
animation: moveUp 1s forwards;
@for $i from 1 through 20 {
&:nth-child(#{$i}) {
animation-delay: (0.1 * $i) + s
}
}
}
}
私の現在の試み(コンパイルされません)のようになりますが、次のようになります。
@mixin inviewChainAnimation($animationName, $from, $to, $duration, $delay, $count:20) {
$from;
@keyframes #{$animationName} {
from {
$from;
}
to {
$to
}
}
.inview ~ & {
animation: #{$animationName} #{$duration} forwards;
@for $i from 1 through #{$count} {
&:nth-child(#{$i}) {
animation-delay: (#{$delay} * $i) + s
}
}
}
}
がどのように私は2つのオブジェクト(から$とを得ることができます$ to)を関数に渡します。それも可能ですか?
申し訳ありませんが、mixinに渡す2つのプロパティがあるので、マークされた答えは問題を解決しません。 [SASS-maps](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#maps)を使用して解決することができます – RWAM
ありがとうございましたRwam、質問と重複した質問は正しくない同じです...私はSASSマップを試してみます。ありがとう...-) –
@cimmanon:もう一度、実際にはそうではない場合、重複して質問を閉じるときには気をつけてください。 – Matt