[英]Highlighted text in a contenteditable div: Get the start and the end of the highlighted text
[英]Scroll highlighted text in div
我使用 frogaloop 制作了视频脚本,并在添加 class.highlight 时尝试自动滚动 div 中的文本。
function checkTime() {
froogInstance.addEvent('playProgress', function(data) {
var curTime = Math.floor(Number(data.seconds));
if(events[curTime]) {
$('.highlight').removeClass('highlight');
events[curTime].addClass('highlight');
$('span:time-span(.highlight):first');
}
});
}
jumpToClickedSentance(args);
initTimes(args);
return this;
}
我尝试通过添加$('span:time-span(.highlight):first');
. 但是,这不起作用。 文本不滚动。
感谢: https://stackoverflow.com/a/24390378/1035130
我添加了这个及其工作
var $container = $("#player_1_transcript");
var $scrollTo = $('.highlight');
$container.animate({scrollTop: $scrollTo.offset().top - $container.offset().top + $container.scrollTop(), scrollLeft: 0},300);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.