我期待用JScrollPane中的 「scrollToElement」 API此功能:jQuery的JScrollPane中的scrollToElement
http://dextersgospel.com/index-test.html
說明它的使用可以在這裏找到:
http://jscrollpane.kelvinluck.com/api.html#scrollTo
的問題,我與「stickToTop」的爭論是一致的。當點擊箭頭,我想它帶來的有針對性的DIV視口(不只是隱約可見,因爲它是目前正在做)的頂部。 「stickToTop」參數應該是處理這個問題,但我無法讓它工作。
我試圖實現這個如下,但沒有運氣:
api.scrollToElement(target_div_id, {stickToTop: true});
,我已經試過:
api.scrollToElement(target_div_id, true);
這裏是我當前全碼:
$(function()
{
/* INITIALIZES jScrollPane on ENTIRE BROWSER WINDOW */
var win = $(window);
var isResizing = false;
var container = $('#full-page-container');
win.bind(
'resize',
function()
{
if (!isResizing) {
isResizing = true;
// Temporarily make the container tiny so it doesn't influence the
// calculation of the size of the document
container.css(
{
'width': 1,
'height': 1
}
);
// Now make it the size of the window...
container.css(
{
'width': win.width(),
'height': win.height()
}
);
isResizing = false;
container.jScrollPane(
{
'showArrows': false,
'mouseWheelSpeed': 75,
'contentWidth': 960, //So content doesn't jump around
'animateScroll': true,
'animateDuration': 600,
'hijackInternalLinks': true //HAD TO HAVE THIS FOR ANCHORS TO WORK!
}
);
}
}
).trigger('resize');
//Awesome scrollToY function for our duct tape arrows - no flicker + built w/jScrollPane
var api = container.data('jsp');
$('.proposal').bind(
'click',
function()
{
var target_div_id = '#' + $(this).attr("title"); // gives you the TITLE of the clicked link
api.scrollToElement(target_div_id, true);
return false;
}
);
});
任何關於如何得到JScrollPane中的「stickToTop」參數workfor了「scrollToElement」的方法是非常感激的幫助d!
絕對BRILLIANCE!非常感謝WTK。在這裏,它的功能完全 - http://dextersgospel.com/index-test.html – nickff
很高興幫助:)順便說一句,你到達那裏的好網站 - 去德克斯特! ;) – WTK
感謝兄弟! 5美元給你一本書的副本......只是說';) – nickff