簡體   English   中英

淡入幻燈片中的圖像?

[英]Fade in images in slideshow?

請看這個小提琴http://jsfiddle.net/rabelais/ayaK2/

  1. 這是圖像和視頻的幻燈片顯示。

  2. 所有圖像和視頻均為全屏顯示。

  3. 當用戶單擊每個圖像/視頻時,它會顯示下一個圖像/視頻。

我的問題:如何使此幻燈片中的圖像淡入?

$(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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM