Come ottenere `morpha.start ()` Dopo 2sec `mouseenter`?
-
13-09-2020 - |
Domanda
Moooools : Come ottenere morpha.start()
dopo 2sec mouseenter
?
window.addEvent('domready',function() {
var morph = new Fx.Morph('resize',{duration:700,delay:400});
$$('#resize').addEvent('mouseenter',function(e){
e.stop();
morpha.start({
width: '200px',
height: '100px'
});
}//It does not work on adding ',2000' here
);
<div id="resize" class="resize">DIV will get bigger after 2sec on mouseenter</div>
. Soluzione
Indica il ritardo.
http://www.jsfiddle.net/dimitar/m6jkt/ Esempio .
document.id('resize').set("morph", {duration:700,delay:400}).addEvents({
mouseenter: function(){
this.store("timer", (function() {
this.morph({
width: '200px',
height: '100px'
});
}).delay(2000, this));
},
mouseleave: function() {
$clear(this.retrieve("timer"));
}
});
.
Questo è stato anche refatturato per usare elemento.Morph che fa l'istanza di classe per te - e annullerà la transizione se si toglie il movimento entro il periodo di inizio di 2 secondi Grazia.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow