2つのNodeを指定して、片方を移動することで中央合わせにする。
X座標・Y座標の両方を揃えるか、片方のみを揃えるかを指定可能。
$positionInPage()を使用しているので、その仕様に準ずる。
動かすNodeには「position: absolute」を設定するので、事前にCSSで設定しておく方が良い。
Blue、Red、Goldの円はCSSで事前に「position: absolute」を設定して絶対配置となっている。
Greenの四角形は「position: relative」を指定しているため、この関数を使用することで「position: absolute」に変わり、親Nodeの高さにも影響を及ぼす。
Sass :
#sample_area {
position: relative;
#circle_blue, #circle_red, #circle_gold {
position: absolute;
}
#square_green {
position: relative;
}
}
Javascript :
$centerToCenter($id('circle_blue'),$id('circle_red'));
$centerToCenter('circle_red','circle_gold');
$centerToCenter($id('circle_gold'),$id('circle_blue'),'X');
$centerToCenter('square_green','circle_red','y');
$centerToCenter('square_green','circle_gold','x');