简体   繁体   English

淡入幻灯片中的图像?

[英]Fade in images in slideshow?

Please see this fiddle http://jsfiddle.net/rabelais/ayaK2/ 请看这个小提琴http://jsfiddle.net/rabelais/ayaK2/

  1. Here is a slideshow of images and videos. 这是图像和视频的幻灯片显示。

  2. All the images and videos are full screen. 所有图像和视频均为全屏显示。

  3. When the user clicks on each image/video it displays the next one along. 当用户单击每个图像/视频时,它会显示下一个图像/视频。

MY QUESTION: How do I make the images in this slideshow fade in? 我的问题:如何使此幻灯片中的图像淡入?

$(function () {

var win = $(window),
    fullscreen = $('.full'),
    image = fullscreen.find('img, video'),
    imageWidth = image.width(),
    imageHeight = image.height(),
    imageRatio = imageWidth / imageHeight,
    currentSlide = 0,
    numSlides = $('.full').length;

function resizeImage() {
    var winWidth = win.width(),
        winHeight = win.height(),
        winRatio = winWidth / winHeight;

    if (winRatio > imageRatio) {
        image.css({
            width: winWidth,
            height: Math.round(winWidth / imageRatio)
        });
    } else {
        image.css({
            width: Math.round(winHeight * imageRatio),
            height: winHeight
        });
    }
}

function advanceToSlide(slidePos){
    slide = $('.full').eq(slidePos);
    slide.show();
    var video = $('video', slide);

    $('video').each(function(){
        $(this).get(0).pause();
    })

    if(video.length){
        console.log(video.get(0).play());
    }   
}

$('.full').on('click', function(){
    $('.full').hide();
    if(currentSlide < numSlides - 1){
        currentSlide = currentSlide + 1;
    } else{
        currentSlide = 0;
    }
    advanceToSlide(currentSlide);
});

$('.full:gt(0)').hide();
resizeImage();

});

http://jsfiddle.net/isherwood/ayaK2/2 http://jsfiddle.net/isherwood/ayaK2/2

function advanceToSlide(slidePos){
    slide = $('.full').eq(slidePos);
    slide.fadeIn();
    ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM