嘿,我与这个脚本作斗争并让它反向工作 -
//modification
var timeline = $('#timeline');
var tlParent = timeline.parent();
var tlHeight = timeline.height();
var tlPHeight = tlParent.height();
//scroll down the content on load
var lastDirection
, newPos = tlHeight - tlPHeight;
$('#timeline_wrapper').animate({scrollTop:newPos + "px"},800,"linear");
//end modification
var $controller = $('#controller')
, scrollableHeight = $('#timeline').height() - $('#timeline_wrapper').height()
, draggableWidth = $('#horizontal_control').width() - $controller.width()
, ratio = scrollableHeight / draggableWidth
, initialOffset = $controller.offset().left;
$controller.draggable({
revert: false,
containment: "parent",
axis: "x",
drag: function (event, ui) {
var distance = ui.offset.left - initialOffset
, currentPos = $('#timeline_wrapper').scrollTop();
var direction = ui.position.left;
(lastDirection < direction) ? $('#timeline_wrapper').scrollTop(currentPos - distance) : $('#timeline_wrapper').scrollTop(currentPos + distance);
lastDirection = ui.position.left;
}
});
我想你会注意到我修改了什么。
这是一个有效的 jsFiddle 演示