Не удалось изменить продолжительность (время) между слайдами в фотораме. Я могу изменить продолжительность перехода, но не продолжительность между изображениями/слайдами. Я попытался изменить интервал для data-autoplay="3000", но это не дало того, что я хотел. Вот мой код:
Как замедлить или ускорить продолжительность между слайдами в jquery fotorama
Ответы (2)
Не уверен, что это то, что вы ищете... Я также предоставил это решение на Как установить разную продолжительность для каждой фоторамы/слайда? (не продолжительность перехода)
Если вы хотите изменить продолжительность до показа следующего слайда для отдельных слайдов... Я справился с этим следующим образом, прослушивая событие fotorama.showend:
Включите это в свой базовый JS-скрипт... Я не тестировал его на странице с несколькими фоторамами, поэтому это может повлиять на все на странице, и вам придется изменить переменные, чтобы настроить таргетинг на конкретную фотораму.
$(function () {
$('.fotorama')
/* Listen to the "showend" event... the "show" event is for the beginning of a transition, while "showend" is at the end of the transition. */
.on('fotorama:showend',
function (e, fotorama, extra) {
/* do a switch on the active index + 1, if you want the current frame at base 1 instead of base 0 */
switch (fotorama.activeIndex + 1){
case 2:
fotorama.setOptions({autoplay: 3000});
break;
case 5:
fotorama.setOptions({autoplay: 15000});
break;
case 6:
fotorama.setOptions({autoplay: 7000});
break;
case 7:
fotorama.setOptions({autoplay: 20000});
break;
case 8:
fotorama.setOptions({autoplay: 2000});
break;
default:
/* You could choose to always set the autoplay to a default value here as shown, but it may be more efficient to just always set it back to default on the first slide of a "default duration" sequence (above ex. slide 2 of slides 2-4, or slide 8 of slides 8-the end), instead of setting a new autoplay value on each and every slide regardless of whether or not it's needed. */
fotorama.setOptions({autoplay: 2000});
break;
}
/* see the event fire in developer console, for debugging only */
console.log('## ' + e.type);
console.log('active frame', fotorama.activeFrame);
console.log('additional data', extra);
}
)
});
Важно понимать, что события "show" и "showend" зависят от слайда, а не от слайд-шоу.
Это также удобно, если вы хотите изменить другие атрибуты после окончания определенных слайдов, например, переключение с кроссфейда на переход слайда или ускорить или замедлить продолжительность перехода.
Если вы хотите воздействовать на что-то в начале перехода, прослушайте "fotorama:show"... полный список событий для прослушивания с кодом отладки консоли из страница API:
$(function () {
$('.fotorama')
// Listen to the events
.on('fotorama:ready ' + // Fotorama is fully ready
'fotorama:show ' + // Start of transition to the new frame
'fotorama:showend ' + // End of the show transition
'fotorama:load ' + // Stage image of some frame is loaded
'fotorama:error ' + // Stage image of some frame is broken
'fotorama:startautoplay ' + // Slideshow is started
'fotorama:stopautoplay ' + // Slideshow is stopped
'fotorama:fullscreenenter ' + // Fotorama is fullscreened
'fotorama:fullscreenexit ' + // Fotorama is unfullscreened
'fotorama:loadvideo ' + // Video iframe is loaded
'fotorama:unloadvideo', // Video iframe is removed
function (e, fotorama, extra) {
console.log('## ' + e.type);
console.log('active frame', fotorama.activeFrame);
console.log('additional data', extra);
}
)
// Initialize fotorama manually
.fotorama();
});
продолжительность перехода данных = "1000"