不知道您想对动画内容做什么,您需要更好地解释这一点或使用显示您的问题的 JSFiddle 进行更新。
我为您创建了一个简单的 JSfiddle,您可以在其中看到如何在 jpane 内滚动到单击元素的位置。您可以在此处的文档中找到您需要的内容:http: //jscrollpane.kelvinluck.com/scroll_to_animate.html
小提琴:http: //jsfiddle.net/Djby5/5/
//wrap in local scope
$(function()
{
var pane = $('.scroll-pane');
pane.jScrollPane(
{
showArrows: true,
animateScroll: true
}
);
var api = pane.data('jsp');
$('.grid li').click(function () {
$(this).removeClass('.grid')
var offset = $(this).offset();
//scroll to the position
api.scrollToY(offset.top);
});
});
我建议您像这样开始简单,然后在此基础上添加您想要的其他动画。覆盖 jpane 中的 animate() 函数并将其替换为您的高级动画,或者仅使用jquery 的 animate()并api.reinitialise();
在您更改或隐藏动画中的 DOM 元素并希望更新 jpane 可滚动区域时调用。
从 jpane 的源代码编辑粘贴:
// This method is called when jScrollPane is trying to animate to a new position. You can override
// it if you want to provide advanced animation functionality. It is passed the following arguments:
// * ele - the element whose position is being animated
// * prop - the property that is being animated
// * value - the value it's being animated to
// * stepCallback - a function that you must execute each time you update the value of the property
// You can use the default implementation (below) as a starting point for your own implementation.
animate: function(ele, prop, value, stepCallback)
{
var params = {};
params[prop] = value;
ele.animate(
params,
{
'duration' : settings.animateDuration,
'easing' : settings.animateEase,
'queue' : false,
'step' : stepCallback
}
);
}