【问题标题】:Scrolling transcript, scrollTop, callback function滚动脚本、scrollTop、回调函数
【发布时间】:2012-06-15 15:44:35
【问题描述】:

这里我正在运行一个成绩单,它也会突出显示当前单词。成绩单向上滚动并且文本失去视图时的问题,突出显示也是如此。我想要发生的是,当高光到达框的顶部时,它应该保持在顶线上的视野中,而不会向上消失。你能帮忙吗???

function runTransript() {

//var player = _V_('video');
 //var videoCurrentTime = player.currentTime();

var transcriptSpeed = 300; //videoCurrentTime; 

transcriptSpeed *= $("#transcript .full-transcript").parent().height();

$("div").css({ top: $(this).parent().height() + 'px' });
$("div").animate({top: -$(this).height() }, transcriptSpeed, 'linear');
$(".transcript-text").each(function(index){

    var curObj = $(this);
    var interval = $(this).attr('time');

    curObj.delay(interval).animate({color: '#5c9127'}, 100, function() {
        $(this).prev().removeAttr("style").prev().removeAttr("style").prev().removeAttr("style");
    });

});

}

【问题讨论】:

    标签: function callback scroll scrolltop


    【解决方案1】:

    函数 runTransript() {

    var player = _V_('video'),
        videoCurrentTime = player.currentTime(),
        lineCount = 1,
        transcriptSpeed = videoCurrentTime;
    
    transcriptSpeed *= $("#transcript .full-transcript").parent().height();
    
    $("div").css({ top: $(this).parent().height() + 'px' });
    $("div").each(function(index){
    
        var curObj = $(this);
        var interval = $(this).attr('time');
    
        curObj.delay(interval).animate({color: '#f0e53d'}, 100, function() {
    
            var pos = $(this).position();
            console.log(pos.left);
            if(parseInt(pos.left) == 15 && index > 0){
                $("div").delay(2000).animate({top: "-"+parseInt(lineCount*35)+"px" }, 'slow', 'linear');
                lineCount++;
            } 
            $(this).addClass('active').prev().removeClass('active').removeAttr("style");
        });
    
    });
    

    }

    【讨论】:

      猜你喜欢
      • 2015-10-11
      • 1970-01-01
      • 2012-02-17
      • 1970-01-01
      • 1970-01-01
      • 2016-08-12
      • 2016-06-02
      • 1970-01-01
      相关资源
      最近更新 更多