2012-06-15 32 views
0

在这里,我正在运行一个脚本,它也突出显示了当前单词。转录本向上滚动,文本丢失视图,问题突出显示。我想要发生的是,当突出显示到盒子的顶部时,它应该停留在顶部视线中,并且不会向上消失。你能帮我吗???滚动脚本,scrollTop,回调函数

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"); 
    }); 

}); 

}

回答

0

功能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"); 
    }); 

}); 

}