Mootools - FX.Scroll no se detendrá cuando se dispara otro evento
-
10-10-2019 - |
Pregunta
No tengo una muy buena comprensión de Javascript por lo appologies antes de empezar.
Me han utilizado con éxito Mootools 1.1 para desplazarse a los elementos onclick eventos. Solía ??FX.Scroll como el ejemplo aquí http://demos111.mootools.net/Fx.Scroll y básicamente arrancado el código de demostración.
Nota:. Si hace clic en un enlace y luego otro con rapidez inmediatamente deja de moverse al primer elemento y se desplaza a la segunda
Ahora estoy tratando de usar Mootools 1.3 para usar los efects de fundido para una galería y han utilizado Más Builder para obtener FX.Scroll. Se está trabajando pero cuando hago clic en un enlace y luego otro de inmediato, sólo se continúa con el primer rollo.
Parece que event.stop no está funcionando.
http://www.mytimephotography.co.uk Estoy utilizando el código: Por favor, ver cualquier otro código fuente en el sitio. window.addEvent('domready', function () {
var scroll = new Fx.Scroll('scrollcontainer', {
wait: false,
duration: 2000,
offset: {'x': 0, 'y': 0},
transition: Fx.Transitions.Quad.easeInOut
})
$('link1').addEvent ('click', function(event){
event = new Event(event).stop();
scroll.toElement('c1');
})
//etc
})
Solución
Use the "link" property of the Fx options object. The default is set to "ignore", which is why the original animation keeps running. Instead, use "chain" if you want it to run after the current animation, or "cancel" if you want it to interrupt the currently running animation.
Alternately, use a faster animation—two seconds is really long! :)
var scroll = new Fx.Scroll('scrollcontainer', {
wait: false,
duration: 2000,
offset: {'x': 0, 'y': 0},
transition: Fx.Transitions.Quad.easeInOut,
link: 'cancel'
});