Anonymous
Нужна помощь в получении индивидуального слайд -шоу на автозаправление
Сообщение
Anonymous » 10 мар 2025, 17:56
Я взял на себя проект, который был построен кем -то другим. На сайте есть пользовательское слайд -шоу на домашней странице. Я внес некоторые изменения в внешний вид/ощущение слайд -шоу на запросы клиента, но последнее, что ему нужно, - это автоматическое. Я знаю о SetInterval , но я не уверен, куда его поместить, или если код должен быть немного скорректирован, прежде чем сбросить это.
Код: Выделить всё
$(document).ready(function() {
// A little script for preloading all of the images
// It"s not necessary, but generally a good idea
$(images).each(function(index, value){
// Ski first image since it is already loaded
if( index != 0 ) {
$("")[0].src = this;
}
});
// Feature Slider Navigation
$('.feature .ei-slider-nav li a').click( function(e) {
e.preventDefault();
var thisLink = $(this);
var navIndex = thisLink.parent('li').index();
thisLink.parents('ul').children('li').removeClass('active');
thisLink.parent('li').addClass('active');
// Is this item already active?
if( !$('.feature .ei-slider-title .ei-slider-title-item:eq('+navIndex+')').hasClass('active')) {
// Fade in/out feature image
$('.feature .ei-slider-large img').animate({opacity: 0}, 500, function() {
// Support for non-opacity browsers
$(this).css('visibility', 'hidden');
// Load new feature image
$(this).attr('src', images[navIndex]);
$(this).attr('alt', imagesAlt[navIndex]);
$(this).css('visibility', 'visible');
$('.feature .ei-slider-large img').animate({opacity: 1}, 500);
});
// Fade in/out feature text
$('.feature .ei-slider-title .ei-slider-title-item.active').fadeOut(500, function() {
$(this).parent().children().removeClass('active');
$('.feature .ei-slider-title .ei-slider-title-item:eq('+navIndex+')').addClass('active').fadeIn();
});
// Fade in/out feature credit
$('.content .ei-slider-credit span.active').fadeOut(500, function() {
$(this).parent().children().removeClass('active');
$('.content .ei-slider-credit span:eq('+navIndex+')').addClass('active').fadeIn();
});
}
});
// Feature Slider Learn More
$('.feature .ei-slider-title-item-learn').click( function(e) {
e.preventDefault();
thisPrev = $(this).prev();
if( thisPrev.css('display') == 'none') {
thisPrev.slideDown();
thisPrev.css('visibility', 'visible');
thisPrev.animate({'opacity': 1}, 500, function() {
});
$(this).html('Hide');
} else {
thisPrev.animate({'opacity': 0}, 500, function() {
thisPrev.slideUp();
thisPrev.css('visibility', 'hidden');
});
$(this).html('Hide');
$(this).html('Learn More');
}
});
});
Спасибо!
Подробнее здесь:
https://stackoverflow.com/questions/294 ... o-autoplay
1741618617
Anonymous
Я взял на себя проект, который был построен кем -то другим. На сайте есть пользовательское слайд -шоу на домашней странице. Я внес некоторые изменения в внешний вид/ощущение слайд -шоу на запросы клиента, но последнее, что ему нужно, - это автоматическое. Я знаю о SetInterval , но я не уверен, куда его поместить, или если код должен быть немного скорректирован, прежде чем сбросить это. [code]$(document).ready(function() { // A little script for preloading all of the images // It"s not necessary, but generally a good idea $(images).each(function(index, value){ // Ski first image since it is already loaded if( index != 0 ) { $("")[0].src = this; } }); // Feature Slider Navigation $('.feature .ei-slider-nav li a').click( function(e) { e.preventDefault(); var thisLink = $(this); var navIndex = thisLink.parent('li').index(); thisLink.parents('ul').children('li').removeClass('active'); thisLink.parent('li').addClass('active'); // Is this item already active? if( !$('.feature .ei-slider-title .ei-slider-title-item:eq('+navIndex+')').hasClass('active')) { // Fade in/out feature image $('.feature .ei-slider-large img').animate({opacity: 0}, 500, function() { // Support for non-opacity browsers $(this).css('visibility', 'hidden'); // Load new feature image $(this).attr('src', images[navIndex]); $(this).attr('alt', imagesAlt[navIndex]); $(this).css('visibility', 'visible'); $('.feature .ei-slider-large img').animate({opacity: 1}, 500); }); // Fade in/out feature text $('.feature .ei-slider-title .ei-slider-title-item.active').fadeOut(500, function() { $(this).parent().children().removeClass('active'); $('.feature .ei-slider-title .ei-slider-title-item:eq('+navIndex+')').addClass('active').fadeIn(); }); // Fade in/out feature credit $('.content .ei-slider-credit span.active').fadeOut(500, function() { $(this).parent().children().removeClass('active'); $('.content .ei-slider-credit span:eq('+navIndex+')').addClass('active').fadeIn(); }); } }); // Feature Slider Learn More $('.feature .ei-slider-title-item-learn').click( function(e) { e.preventDefault(); thisPrev = $(this).prev(); if( thisPrev.css('display') == 'none') { thisPrev.slideDown(); thisPrev.css('visibility', 'visible'); thisPrev.animate({'opacity': 1}, 500, function() { }); $(this).html('Hide'); } else { thisPrev.animate({'opacity': 0}, 500, function() { thisPrev.slideUp(); thisPrev.css('visibility', 'hidden'); }); $(this).html('Hide'); $(this).html('Learn More'); } }); }); [/code] Спасибо! Подробнее здесь: [url]https://stackoverflow.com/questions/29417550/need-help-getting-custom-slideshow-to-autoplay[/url]