MooToolsã®ã¢ãã¡ãŒã·ã§ã³ã
åºæ¬ååã ã¯ã©ã¹Fxã
ããã§ãä»æ¥ã¯ã¢ãã¡ãŒã·ã§ã³ãè¡ããŸãã ãŸããMooToolsã§ã¢ãã¡ãŒã·ã§ã³ã®åçãã©ã®ããã«å®è£ ãããŠããããç解ããå¿ èŠããããŸãã MooToolsã®ã¢ãã¡ãŒã·ã§ã³ã¯ãæéã®çµéã«äŒŽãèŠçŽ ã®äžéšã®ããããã£ã®å€åïŒé·ç§»ïŒã§ããããšãã°ãå·Šã®CSSããããã£ã®å€æŽã¯æ°Žå¹³æ¹åã®åãã§ãããèæ¯è²ã¯å¡ãã€ã¶ãã®è²ã®æ»ãããªå€åã§ããMooToolsã¯Fxã¯ã©ã¹ã䜿çšããŠãã¢ãã¡ãŒã·ã§ã³å¹æãäœæããŸãã ããããçš®é¡ã®ã¢ãã¡ãŒã·ã§ã³ãå®è£ ãããã¹ãŠã®ã¯ã©ã¹ã¯ãFxãç¶æ¿ããŸãã ã¢ãã¡ãŒã·ã§ã³ã®ãã«ããŒã¡ãœããã¯ããã®ã¯ã©ã¹ã§å®çŸ©ãããŸãã
- start-ãã®ã¡ãœããã¯é·ç§»ãéå§ããŸãã
- set-ã¢ãã¡ãŒã·ã§ã³åããããã©ã¡ãŒã¿ãŒã®å€ãå€æŽããŸãã é·ç§»ã®åã¹ãããã§åŒã³åºãããŸãã æå³ã«é¢ããŠèšãã°ãããã¯æœè±¡ã¡ãœããã§ãã åã¢ãã¡ãŒã·ã§ã³ãã©ã°ã€ã³ã®å®è£ ã¯ãç¬èªã®æ¹æ³ã§ã»ããããªãŒããŒã©ã€ãããå¿ èŠããããŸãã
- cancel-çŸåšã®ã¢ãã¡ãŒã·ã§ã³ããã£ã³ã»ã«ããŸãã
- pause-çŸåšã®ã¢ãã¡ãŒã·ã§ã³ãäžæåæ¢ããŸãã
- resume-äžæåæ¢ããã¢ãã¡ãŒã·ã§ã³ãåéããŸãã
- fps-ã¢ãã¡ãŒã·ã§ã³ã®1ç§ãããã®ãã¬ãŒã ã ããã¯ããã°ãã¢ãã¡ãŒã·ã§ã³ã®ããªããããããç¹åŸŽã¥ããŸã-ããã¯ããã¹ã ãŒã¶ãŒãã§ãã
- åäœ -枬å®åäœãããšãã°ããemãããpxãããïŒ ãã CSSããããã£ãå€æããããã«äœ¿çšãããŸãã
- link-é·ç§»äžã«startãåŒã³åºããããšãã®ã¢ãã¡ãŒã·ã§ã³ã®åäœãç¹åŸŽä»ãããªãã·ã§ã³ã 以äžã®å€ãåãããšãã§ããŸãïŒ ç°ãªããªã³ã¯å€ã®äŸ ïŒïŒ
- 'ignore'-ã¢ãã¡ãŒã·ã§ã³äžã®ãã¹ãŠã®éå§åŒã³åºãã¯ç¡èŠãããŸãã ããã©ã«ãã§äœ¿çšãããŸãã
- 'cancel'-çŸåšã®ã¢ãã¡ãŒã·ã§ã³ãåæ¢ããéå§ããããã©ã¡ãŒã¿ãŒã§æ°ããã¢ãã¡ãŒã·ã§ã³ãéå§ãããŸãã
- ããã§ãŒã³ã -ã¢ãã¡ãŒã·ã§ã³äžã®ãã¹ãŠã®éå§åŒã³åºãããã§ãŒã³ã«è¿œå ãããçŸåšã®ã¢ãã¡ãŒã·ã§ã³ãçµäºãããšããã«ã¢ãã¡ãŒã·ã§ã³ãéå§ãããŸãã
- duration-ã¢ãã¡ãŒã·ã§ã³ã®ç¶ç¶æéã
- é·ç§»ã¯é·ç§»æ¹çšåŒã§ãã ããå€ãã®é·ç§»æ¹çšåŒã以äžã§æ€èšããŸãã
- ãã©ã³ãžã·ã§ã³ã®éå§ããçŸåšã®ç¬éãŸã§ã®çµéæéã¯ç¶ç¶æéã§é€ç®ãããããã0ãã1ãŸã§ã®æ°åãã¢ãã¡ãŒã·ã§ã³ã®é²è¡ãç¹åŸŽä»ããŸãã é²è¡ç¶æ³ãšåŒã³ãŸãããã
- ãã®çªå·ã¯é·ç§»é¢æ°ã«æž¡ãããŸãïŒä»¥äžã§èª¬æããŸãïŒã é·ç§»é¢æ°ã®èšç®çµæã¯ãã«ã¿ãšåŒã°ããŸãã
- ã¢ãã¡ãŒã·ã§ã³åããããã©ã¡ãŒã¿ãŒã®å€ã¯ã次ã®ããã«èšç®ãããŸããparam =ïŒto-fromïŒÃdelta + fromãããã§fromã¯ãã©ã¡ãŒã¿ãŒã®åæå€ãtoã¯ãã©ã¡ãŒã¿ãŒã®æçµå€ã§ãã æããã«ããã«ã¿ã0ã®å Žåã¯ãã©ã¡ãŒã¿ãŒã®åæå€ãååŸãã1ã®å Žåã¯æçµå€ãååŸããŸãã
Fxã¯ã©ã¹èªäœãæœè±¡çã§ãããã€ãŸããã¢ãã¡ãŒã·ã§ã³åãããã¢ãã¡ãŒã·ã§ã³ã®ååãå®è£ ããããã«äžè¬çãªããŒã¿ã®ã¿ãæäœããããšã匷調ãã䟡å€ããããŸãã çŽæ¥ã¢ãã¡ãŒã·ã§ã³ã¯Fxã®çžç¶äººã«ãã£ãŠè¡ãããŸãã ã»ãšãã©ã®å ŽåãèŠçŽ ã®ããŸããŸãªCSSããããã£ãã¢ãã¡ãŒã·ã§ã³åããã¯ã©ã¹ã¯ãHTMLããŒãžã®èŠçŽ ãã¢ãã¡ãŒã·ã§ã³åããããã«äœ¿çšãããŸãã ãããã®ã¯ã©ã¹ã«ã€ããŠèª¬æããéCSSããããã£ã®ã¢ãã¡ãŒã·ã§ã³ãå®è£ ããç¬èªã®ã¯ã©ã¹ãäœæããå Žåãæ€èšããŸãã
é·ç§»æ¹çšåŒã ç¬èªã®æ¹çšåŒãæžãã
åæããŸããããŒãžäžã®èŠçŽ ã移åããã¢ãã¡ãŒã·ã§ã³ã¯ããã¹ã®çµããã§çªç¶éå§ããçªç¶åæ¢ããå ŽåãããŸãèŠæ ãããããããŸããã ããã¯ãïŒäžèšã§èª¬æããïŒãã«ã¿å¢åãå šäœãéããŠäžå®ã®ãŸãŸã§ããå Žåã«çºçããŸãã ããã¯ç·åœ¢é·ç§»ãšåŒã°ãããã®æ¹çšåŒã¯delta = progressã§ãã 0ãã1ãŸã§ã®è€æ°ã®é²è¡å€ãé£ç¶ããŠååŸããããããæ¹çšåŒã«ä»£å ¥ãããšã0ã§çªç¶å§ãŸã1ã§çªç¶çµäºããéåžžã®è¡ãåŸãããŸããåã®æ®µèœããããã®ãããªé·ç§»æ¹çšåŒããã«ã¿å¢åãèšç®ããããã®æ³åã§ããããšãã»ãŒæããã«ãªã£ãããšãé¡ã£ãŠããŸãã 幞ããªããšã«ãMooToolsã«ã¯ã¢ãã¡ãŒã·ã§ã³ãã¹ã ãŒãºãã·ã£ãŒãããã§ãŒãããžã£ã³ããªã©ã«ããäžé£ã®æ³åããããŸãããããã ãã§ã¯ååã§ã¯ãããŸãããç¬èªã®æ¹çšåŒãæžããŸãã ããããããã«ã€ããŠã¯åŸã§ã ããã§ã¯ãæšæºæ¹çšåŒãšã¯äœããèŠãŠã¿ãŸãããã
- ç·åœ¢ -çŽæ¥ïŒãã«ã¿=é²è¡ïŒã
- Quadã¯2次é¢æ°ã§ãïŒdelta = progress 2 ïŒã
- 3次-3次é¢æ°ïŒãã«ã¿=é²è¡ç¶æ³3 ïŒã
- ã¯ã©ãŒããã«ã¿=é²è¡ç¶æ³4 ã
- ã¯ã€ã³ããã«ã¿=é²è¡ç¶æ³5 ã
- Powã¯ãäžè¬çãªã¹ãé¢æ°delta = progress x ïŒããã©ã«ãã¯6ïŒã§ãã
- Expoã¯ææ°é¢æ°ã§ãïŒdelta = 2 ïŒprogress-1ïŒÃ8 ïŒã
- Circ-åã®1/4ïŒãã«ã¿= 1-sinïŒacosïŒé²è¡ïŒïŒïŒã
- æ£åŒŠ -æ£åŒŠæ³¢ã®æçïŒãã«ã¿= 1-æ£åŒŠïŒïŒ1-é²è¡ïŒÃÏ/ 2ïŒïŒã
- æ»ã -æåã«ãã«ã¿ããã€ãã¹ã«åŒãã次ã«ã¹ã ãŒãºã«1ã«ããŸãã
- ããŠã³ã¹ -ãžã£ã³ãé·ç§»ã
- ãšã©ã¹ãã£ã㯠- ãšã©ã¹ãã£ãã¯é·ç§»ïŒå¯äžã®é¢é£ä»ãã¯ãšã©ã¹ãã£ãã¯:)ã§ãã
- easeIn-ããã©ã«ãã§äœ¿çšãããäœãå€æŽããŸããã
- easeOut-åŒ1-é·ç§»ïŒ1-é²è¡ïŒã䜿çšããŠãã«ã¿å€ãèšç®ããé·ç§»æ²ç·ãæ¡åŒµããŸãã
- easeInOut-é·ç§»ã®äžéãŸã§ãé·ç§»ïŒ2Ãé²è¡ïŒåŒã䜿çšããŠãã«ã¿ãèšç®ãããã®åŸ-ïŒ2-é·ç§»ïŒ2Ãé²è¡ïŒïŒ/ 2ã«åŸã£ãŠã1ã€ã®é·ç§»ã§2ã€ã®æ²ç·ãçµã¿åãããŸãïŒçŽç·ãšè©³çŽ°æ²ç·ã
ãããŠãããã«ãã®ãžã£ã³ãã¢ãã¡ãŒã·ã§ã³ããããŸãã
ã¯ã©ãŒã¿ãŒãµãŒã¯ã«ã
ã¬ã
ææ°é¢æ°ã
äºåºŠã
æ£åŒŠæ³¢ã®ãããã
ã¢ãã¡ãŒã·ã§ã³ã§ã®ããŸããŸãªé·ç§»æ¹çšåŒã®äœ¿çšã瀺ãäŸã¯ã ããã«ãããŸã ã
ãããŠçªç¶ãããŸããŸãªçµã¿èŸŒã¿æ¹çšåŒã®äžã«å¿ èŠã¯ãããŸãããïŒ åé¡ã¯ãããŸãããããã€ã§ãèªåã§æžãããšãã§ããŸãã çæ³çã«ã¯ãæ¹çšåŒã¯ãåŒæ°ããŒãã®å Žåã«0ãè¿ãããŠããã£-1ãè¿ãããã«ããå¿ èŠããããŸãããã®å Žåãã¢ãã¡ãŒã·ã§ã³ã®éå§æãšçµäºæã«ã¢ãã¡ãŒã·ã§ã³åããããã©ã¡ãŒã¿ã®ãžã£ã³ãã¯ãããŸããã
äŸãšããŠãå¿é»å³ã®å€åãã·ãã¥ã¬ãŒãããæ¹çšåŒãæžããããšæããŸããã ãã¡ããã誰ãã®å¿é»å³ãããã€ã³ããåããããããå€é åŒã«è£éããããšãã§ããŸãïŒ3幎ç®ã«æžãããããªããã°ã©ã ã®å Žå:)ããæçµçšéã§ã¯ããã»ã©æ£ç¢ºã§ã¯ãªãããªãœãŒã¹ã倧éã«æ¶è²»ããŸããã ãããã£ãŠãé¢æ°ã¯è€éã§ããããšãå€æããŸããã å®çŸ©ã®æ¡ä»¶ä»ããã¡ã€ã³å šäœïŒ0ãã1ïŒã¯ééã«åå²ãããåééã«ã¯ç¬èªã®å°ããªæ©èœããããŸãã çµæã¯æ¬¡ã®ãšããã§ãã
ã芧ã®ããã«ããquadroé¢æ°ãã¯ããŒãããã®ã¹ã ãŒãºãªäžæã®ããã®æåã®ã®ã£ããã§å®çŸ©ããããã®åŸãããŸããŸãªåŸé ãšé·ãã®çŽç·ã®ã»ããã§å®çŸ©ãããŸãã æ²ç·ã®ããã«èŠããæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
次ã®ããã«ããã®é¢æ°ãFx.Transitionsãªããžã§ã¯ãã«è¿œå ããŸãã
Fx.Transitions.extend({
Heartbeat: function (x){
if (x < 0.3)
return Math.pow(x, 4) * 49.4;
if (x < 0.4)
return 9 * x - 2.3;
if (x < 0.5)
return -13 * x + 6.5;
if (x < 0.6)
return 4 * x - 2;
if (x < 0.7)
return 0.4;
if (x < 0.75)
return 4 * x - 2.4;
if (x < 0.8)
return -4 * x + 3.6;
if (x >= 0.8)
return 1 - Math.sin(Math.acos(x));
}
});
移è¡ãªãã·ã§ã³ãšããŠæž¡ãããšã§äœ¿çšã§ããããã«ãªããŸããïŒæ³šïŒãã®äŸã§ã¯Fx.Morphãã©ã°ã€ã³ã䜿çšããŠããŸãããããã«ã€ããŠã¯ä»¥äžã§èª¬æããŸãããçŸæç¹ã§ã¯åã«Fxã®åŸç¶ãšèŠãªãããšãã§ããŸãã
var fx = new Fx.Morph($( 'Heart' ), { transition: Fx.Transitions.Heartbeat, duration: 900, link: 'chain' });
// 10 .
for ( var i = 0; i < 10; i++){
// .
fx.start({
'width' : 265,
'height' : 238,
'margin-left' : -20,
'margin-top' : -20
});
// .
fx.start({
'width' : 225,
'height' : 198,
'margin-left' : 0,
'margin-top' : 0
});
}
HTMLã³ãŒãã«ã¯èŠçŽ ã1ã€ã ããããŸãã
<img id="Heart" src="./images/heart.png" />
çããäŸãããã«ãããŸã ã èå³æ·±ãå¹æïŒã¹ã¯ãªããã®ãã¹ãäžã«Drum'n'Bassãèãããšããããã®å¿èã®éŒåã¯é³æ¥œã«åãããŠçºçããããã§ãïŒèªåã§è©ŠããŠã¿ãŠãã ããïŒã
ããããŸãããå€åç§éã¯çæ³çãªäººéã®å¿é»å³ãéæããªãã£ãããããã«ããããããç§éã¯ç§éã®æ©èœãæžããã çµå±ã®ãšãããããã¯ããã»ã©é£ãããããŸãã:)ã
ãã§ãŒã³ã ã¢ãã¡ãŒã·ã§ã³åãããå€æã®ã¯ã©ããã
éåžžã«å€ãã®å Žåãããã€ãã®é£ç¶ããå€æãæå®ããŠãåã®å€æãçµäºããåŸã«æ¬¡ã®åå€æãå®è¡ããå¿ èŠããããŸãã åã«é çªã«åŒã³åºãå Žåãããã©ã«ãã§ã¯åŸç¶ã®ååŒã³åºãã¯ç¡èŠãããŸãïŒFxã¯ã©ã¹ã®ãªã³ã¯ãªãã·ã§ã³ãåç §ïŒã ãªã³ã¯ãããã§ãŒã³ãã«èšå®ãããŠããå ŽåãåŸç¶ã®ãã¹ãŠã®åŒã³åºãããã§ãŒã³ã«è¿œå ãããé 次å®è¡ãããŸãããã ãããã§ãŒã³ãäœæããããã®ç¹å¥ãªæ§æããããŸãã ãããã¯Chainã¯ã©ã¹ã§å®è£ ãããŸãã 次ã®3ã€ã®ã¡ãœãããå«ãŸããŠããŸãã
- chain-é¢æ°ããã§ãŒã³ã®æåŸã«è¿œå ããŸãã
- callChain-ãã§ãŒã³å ã®æ¬¡ã®é¢æ°ãåŒã³åºãããã§ãŒã³ããåé€ããŸãã
- clearChain-ãã§ãŒã³ãã¯ãªã¢ããŸãã
ãã£ã¿ãã©ãŒèªäœã¯éåžžã®divã§ãããå·Šãäžãå¹ ãé«ãã®CSSããããã£ãå€æŽããŠåãã®å¹æãäœæããŸãïŒãããã¯ããè²ããªã¢ã«ã«å€æŽãããŸãïŒã ãã£ã¿ãã©ãŒã®ã¹ãããã¯2ã€ã®æ®µéã§æ§æãããŸããæåã®æ®µéã¯é ãæ£ããå Žæã«ç§»åãã2çªç®ã®æ®µéã¯å°Ÿãé ã«åŒãå¯ããŸãã ãã®äŸã§ã¯Fx.Morphã䜿çšããŠããŸããããã«ãããè€æ°ã®CSSããããã£ãåæã«ã¢ãã¡ãŒã·ã§ã³åã§ããŸããããã«ã€ããŠã¯ã以äžã§è©³çŽ°ã«èª¬æããŸãã
var CaterpillarController = new Class({
// Chain .
Implements: Chain,
// .
largeSize: 200,
smallSize: 10,
// .
initialize: function (caterpillar){
this .caterpillar = $(caterpillar);
// Fx.Morph start.
this .fx = new Fx.Morph( this .caterpillar, { duration: 900, transition: Fx.Transitions.Expo.easeOut, link: 'chain' });
// .
this .fx.addEvent( 'chainComplete' , this .callChain.bind( this ));
return this ;
},
// .
// (dimension: â true, â false)
// (direction: â true, â false).
move: function (dimension, direction){
var dimensions = this .caterpillar.getCoordinates();
var options1, options2;
// .
if (dimension){
// .
if (direction){
options1 = { 'width' : dimensions.width + this .largeSize };
options2 = { 'left' : dimensions.left + this .largeSize, 'width' : this .smallSize };
} else {
options1 = { 'left' : dimensions.left - this .largeSize, 'width' : this .largeSize + this .smallSize };
options2 = { 'width' : this .smallSize };
}
} else {
// .
if (direction){
options1 = { 'height' : dimensions.height + this .largeSize };
options2 = { 'top' : dimensions.top + this .largeSize, 'height' : this .smallSize };
} else {
options1 = { 'top' : dimensions.top - this .largeSize, 'height' : this .largeSize + this .smallSize };
options2 = { 'height' : this .smallSize };
}
}
// ( ).
$extend(options1, { 'background-color' : '#7CCB26' });
$extend(options2, { 'background-color' : '#4C9004' });
//
// ( , link 'chain').
this .fx.start(options1);
this .fx.start(options2);
return this ;
}
});
window.addEvent( 'domready' , function (){
// move .
new CaterpillarController( 'Caterpillar' ).move( true , true ).
chain( function () { this .move( false , true ); }).
chain( function () { this .move( true , false ); }).
chain( function () { this .move( false , true ); }).
chain( function () { this .move( true , true ); }).
chain( function () { this .move( false , false ); }).
chain( function () { this .move( true , false ); }).
chain( function () { this .move( false , false ); });
});
ããã§ã®çããäŸã ãããŠãããã¯ãã§ãŒã³ãšã¯ãŸã£ããé¢ä¿ã®ãªãäŸã§ã-ã¡ãã£ãšãã空æ³ã§ãããã¯ãŒã«ã§ãã
ç¬èªã®å€æ°ã®ã¢ãã¡ãŒã·ã§ã³ã
ãããŸã§ãããŸããŸãªCSSããããã£ã®ã¢ãã¡ãŒã·ã§ã³ã䜿çšããŠããŸããã ããããèšäºã®åé ã§ææããããã«ãFxã¯ã©ã¹ã¯äœã§ãã¢ãã¡ãŒã·ã§ã³åã§ããŸãã ãããã£ãŠãFxã®çžç¶äººãäœæããŠã¿ãŠãã ããã åºç€ãšããŠã ãã®ãããã¯ã§æžããã¬ãªã¹ã¿ããã¹ã¯ãªããã®æ¹è¯çã䜿çšããŸã ã ãã®äžã§äœãã¢ãã¡ãŒã·ã§ã³åã§ããŸããïŒ ããšãã°ãã€ã³ãžã±ãŒã¿ã®å転è§åºŠã ã¬ãªã¹ã¿ããã1åã¯ãªãã¯ãããšãæŒãå Žæã«ã€ã³ãžã±ãŒã¿ãããã«è¡šç€ºãããããšãæãåºããŠãã ããã ãããããã®ç§»è¡ãã¢ãã¡ãŒã·ã§ã³åãããšã©ããªããŸããïŒ ããã¯é¢çœãã§ãããããããŠããªãã¯ã»ãã®æ°è¡ãæžãå¿ èŠããããŸã:)ã ãããã£ãŠãæ¬æ ŒçãªFxã®åå«ãäœæããããã«å¿ èŠãªãã®ã¯æ¬¡ã®ãšããã§ãã- ExtendsïŒFxãç¶æ¿ã®ããã«ã¯ã©ã¹ã®èª¬æã«è¿œå ããŸãã
- åºæ¬ã³ã³ã¹ãã©ã¯ã¿ã«ãªãã·ã§ã³ãæž¡ããŸãã
- setã¡ãœãããåå®çŸ©ããŠãã¢ãã¡ãŒã·ã§ã³åããããã©ã¡ãŒã¿ãŒã®å€ããã©ã¡ãŒã¿ãŒã®ãç©çãã«é©çšããŸãããã®å Žåãè§åºŠã®å€ã§ã€ã³ãžã±ãŒã¿ãŒãå転ããŸãã
- startãåŒã³åºããŠãã¢ãã¡ãŒã·ã§ã³ãéå§ããŸãã
set: function (now){
// now â .
this .oldMouseAngle = this .mouseAngle = this .angle = now;
this .updateIndicatorPosition();
}
è§åºŠãå³åº§ã«å€æŽããã®ã§ã¯ãªããããŠã¹ã¯ãªãã¯ã«å¿çããã¡ãœãããstartã¡ãœãããåŒã³åºããã€ã³ãžã±ãŒã¿ãŒã®å転è§åºŠã®çŸåšã®å€ãšãã¢ãã¡ãŒã·ã§ã³ã®çµäºåŸã«å転ããè§åºŠã®å€ãæž¡ãããã«ãªããŸããã
captureMouse: function (e){
this .captured = true ;
var mouseAngle = this .getMouseAngle(e);
if ((mouseAngle >= this .options.minAngle) && (mouseAngle <= this .options.maxAngle))
// .
this .start( this .angle, mouseAngle);
}
ããã ãã§ãã ããã§èŠãããšãã§ããã¢ãã¡ãŒã·ã§ã³åãããé·ç§»ããããŸãã
æšæºã®ã¢ãã¡ãŒã·ã§ã³ãã©ã°ã€ã³ã
Fx.Tweenã
ãã®ã¯ã©ã¹ã¯ãèŠçŽ ã®CSSããããã£ãã¢ãã¡ãŒã·ã§ã³åããæãåçŽãªã¯ã©ã¹ã§ãã åäœãããã«ã¯ãã¢ãã¡ãŒã·ã§ã³èŠçŽ ãžã®ãªã³ã¯ãã¢ãã¡ãŒã·ã§ã³CSSããããã£ã®ååãããã³å€ã®ç¯å²ãå¿ èŠã§ãã äœæäŸïŒvar myFx = new Fx.Tween(element, [, options]);
ããŸããŸãªé·ç§»æ¹çšåŒã«åºã¥ãäŸã¯ ããã®ã¯ã©ã¹ã«åºã¥ããŠããŸãã
// CSS- top 'Ball'.
var fx = new Fx.Tween( 'Ball' , { property: 'top' , duration: 900, link: 'cancel' });
var transitionSelect = $( 'Transition' );
var modifierSelect = $( 'Modifier' );
var test = $( 'Test' );
// .
modifierSelect.addEvent( 'change' , startAnimation);
transitionSelect.addEvent( 'change' , startAnimation);
test.addEvent( 'click' , startAnimation);
function startAnimation(){
// 'sine:in'.
fx.options.transition = transitionSelect.value + modifierSelect.value;
// .
fx.start(60, 400);
}
ãã®äŸã®HTMLã³ãŒãã«ã¯ãã¢ãã¡ãŒããããããŒã«ãšãã¹ãŠã®æ¶é²å£«çšã®ãã¿ã³ã®2ã€ã®ããããããŠã³ãªã¹ãããããŸãã
Fx.Morphã
èŠçŽ ã®è€æ°ã®CSSããããã£ãåæã«ã¢ãã¡ãŒã·ã§ã³åã§ãããããFx.Tweenãããé »ç¹ã«äœ¿çšãããŸãã ã³ã³ã¹ãã©ã¯ã¿ã¯ãããããã£ãªãã·ã§ã³ããªãããšãé€ããŠãFx.Tweenãšã»ãŒåãã§ããã代ããã«ãã¢ãã¡ãŒã·ã§ã³åããCSSããããã£ãšç¯å²ãèšè¿°ãããªããžã§ã¯ããstartã¡ãœããã«æž¡ãããŸãã äŸïŒmorph.start({
'margin-left' : [0, 10],
'background-color' : [ '#EEE' , '#555' ]
});
2ã€ã®CSSããããã£ãã¢ãã¡ãŒã·ã§ã³åãããããšãæå³ããŸãïŒmargin-leftïŒ0ãã10ïŒããã³background-colorïŒ '#EEE'ãã 'ïŒ555'ïŒã å€ã®ç¯å²ã¯çç¥ã§ããŸãããæçµå€ã®ã¿ã瀺ããèŠçŽ ã¹ã¿ã€ã«ã§æå®ãããçŸåšã®å€ãåæå€ãšããŠäœ¿çšãããŸãã äŸã¯ãFx.Morphã䜿çšããŠã¢ãã¡ãŒã·ã§ã³ã¡ãã¥ãŒãäœæããããšã§ãã
var menuHeadItems = $$( '#Menu .MenuHeadItem' );
menuHeadItems.each( function (item, i){
var morph = new Fx.Morph(item, { duration: 900, transition: Fx.Transitions.Elastic.easeOut, link: 'cancel' });
// 100i ms.
// : opacity margin-left. ""
// 1.
morph.start.delay(i * 100, morph, {
'opacity' : [0, 1],
'margin-left' : 0
});
item.addEvents({
// .
'mouseenter' : function (){
morph.start({
'margin-left' : 8,
'background-color' : '#DDD'
});
},
// .
'mouseleave' : function (){
morph.start({
'margin-left' : 0,
'background-color' : '#EEE'
});
}
});
});
ã¡ãã¥ãŒã衚瀺ã§ããŸãã
å ¬åŒã®äŸ ã
Fx.Slideã
ã©ããããç«ã¡å»ã£ããç«ã¡å¯ã£ããããäœããå¿ èŠãªãšãã¯ããšãŠã䟿å©ãªã¯ã©ã¹ã§ãã ãã¶ã€ããŒã¯ä»¥åã®ãã¶ã€ããŒãšéåžžã«ãã䌌ãŠããã®ã§ãããã§ã¯è©³ãã説æããŸããã 圌ã¯ããã«ããã€ãã®ãªãã·ã§ã³ãç解ããŠãããšããèšããŸããããæãéèŠãªã®ã¯ã¢ãŒãã§ããã¢ãŒãã¯ãåºå£ãã®æ¹åã決å®ããŸãïŒåçŽãŸãã¯æ°Žå¹³ã ãã®ã¯ã©ã¹ã«åºã¥ããŠãã¢ãã¡ãŒã·ã§ã³ã¡ãã¥ãŒã䜿çšãã2ã€ã®äŸããã1ã€äœæãããŸãã1ã€ç®ãš2ã€ç®ã§ããå ¬åŒã®äŸ ã
Fx.Elementsã
ä»»æã®æ°ã®èŠçŽ ã®ä»»æã®æ°ã®CSSããããã£ãåæã«äŸ¿å©ã«ã¢ãã¡ãŒã·ã§ã³åã§ããŸãã èŠçŽ ã®é åããã®ã³ã³ã¹ãã©ã¯ã¿ã«æž¡ãããå€æãå®è¡ãããŸãã ãããŠããã¹ãŠã®é åã¯startã¡ãœããã«ãããŸã-å€ââæã®ããã®ãªããžã§ã¯ãã®é åãããã«æž¡ãããŸãã ã³ã³ã¹ãã©ã¯ã¿ãŒã«æž¡ãããé åã®åèŠçŽ ã¯ãstartã«æž¡ãããé åã®èŠçŽ ã«å¯Ÿå¿ããããšãããããŸãã ãããã£ãŠãèŠçŽ ã®å€§éã¢ãã¡ãŒã·ã§ã³ãå®è¡ãããŸãã次ã®äŸã§ã¯ãèŠçŽ ã®äžã«ããŠã¹ã眮ããšèŠçŽ ã®é åã®éæ床ãå€åããçŸåšã«ãŒãœã«ã®äžã«ããèŠçŽ ã«èŠçŽ ãè¿ã¥ãã»ã©éæ床ãäœããªããããé ãã«ãªããŸãã
var elements = $$( '#ElementsContainer .Element' );
var elementsFx = new Fx.Elements(elements, { duration: 500, link: 'cancel' });
elements.each( function (element, i){
// .
element.addEvent( 'mouseenter' , function (){
var arg = {};
//
// .
elements.each( function (element, j){
arg[j] = { opacity: 1 - Math.min(Math.abs(i - j), 5) / 8 };
});
// .
elementsFx.start(arg);
});
});
çããŠããäŸ ã
MooToolsã®èå³æ·±ãã¡ãã¥ãŒãªãã·ã§ã³ ã
èªè ããMooToolsã§ã®ã¢ãã¡ãŒã·ã§ã³ã®å®è£ ãããæ·±ãæãäžããããšæã£ãããšãé¡ã£ãŠããŸãã ããã§èª¬æããå 容ã®ã»ãšãã©ã¯ãä»ã®ãã¬ãŒã ã¯ãŒã¯ã«ãé©çšã§ããã¯ãã§ãã
ãæž èŽããããšãããããŸããã