使用 jScrollPane 时移动/重新定位滚动条

发布于 2024-09-30 10:58:13 字数 847 浏览 3 评论 0原文

我一直在寻找答案,但到目前为止还没有运气。

目前,滚动条和箭头位于同一位置内 div 作为可滚动内容 - 在大多数情况下这是有意义的。我 想知道是否有办法放置滚动条和箭头 在 html 页面的不同位置中的这个 div 之外?有没有 一种指定他们应该去的地方的方法?

示例:

<div id="content">
   Lorem ipsum....
</div>

变成:

<div id="content">
   <div class="scrollpane">
       Lorem ipsum....
   </div>
   <div class="scroll-bar">
       ### scroll bar and arrows here ###
   </div>
</div>

但我想得到这个:

<div id="content">
   <div class="scrollpane">
       Lorem ipsum....
   </div>
</div>
[other html other html and content other html]
<div id="scrollbar-here">
 ### scroll bar and arrows here ###
</div>

非常感谢任何帮助,或者我错过的答案的链接 同样会有帮助。我正在使用 jquery1.4.3 和 jScrollPane - v2.0.0beta6

I've had a look for the answer but with no luck so far.

At the moment the scrollbar and arrows are postioned inside the same
div as the scrollable content - which in most cases makes sense. I
want to know if there is a way to place the scrollbar and arrows
outside of this div in a different location in the html page? Is there
a way to specify the place they should go?

Example:

<div id="content">
   Lorem ipsum....
</div>

Gets turned into:

<div id="content">
   <div class="scrollpane">
       Lorem ipsum....
   </div>
   <div class="scroll-bar">
       ### scroll bar and arrows here ###
   </div>
</div>

But I want to get this:

<div id="content">
   <div class="scrollpane">
       Lorem ipsum....
   </div>
</div>
[other html other html and content other html]
<div id="scrollbar-here">
 ### scroll bar and arrows here ###
</div>

Any help much appreciated, or a link to the answer that I've missed
would be equally helpful. I'm using jquery1.4.3 and jScrollPane -
v2.0.0beta6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷血 2024-10-07 10:58:13

我刚刚回答了您向谷歌小组提出的问题:
http://groups.google.com/group/jscrollpane/browse_thread/thread/ff2e10b8d784fed6

这是其他搜索者的答案:


不幸的是,目前不支持。您可以尝试通过以下几种方法来实现它:

  1. 在 jspVerticalBar 和/或 jspHorizo​​ntalBar 上使用绝对定位,并尝试移动它们,以便它们出现在文档中的其他位置。
  2. 如果您只对箭头感兴趣,那么您可以轻松地将一些不同的按钮连接到API,以便它们调用scrollBy来执行滚动[参见http://jscrollpane.kelvinluck.com/scroll_to.html]。此外,您可以连接 jsp-scroll-x/y 事件,在相关时将自制箭头标记为禁用[请参阅 http://jscrollpane.kelvinluck.com/events.html]。您可以使用 CSS 来隐藏“真正的”滚动条和箭头。
  3. 您可以尝试使用javascript来移动元素(例如类似 $('#myDiv').append($('.jspVerticalBar')); ) - 不保证这不会有一些奇怪的不过有副作用!

希望它能给你一些想法。如果你想将其作为功能请求添加到 github 问题列表中,那么我会尝试在将来查看它(不过不会很快 - 我现在真的很忙于客户工作) 。

I just answered this question where you had posed it to the google group:
http://groups.google.com/group/jscrollpane/browse_thread/thread/ff2e10b8d784fed6

Here is the answer for other searchers:


Unfortunately that isn't currently supported. There are a few of ways you could attempt to achieve it:

  1. Use absolute positioning on the jspVerticalBar and/or jspHorizontalBar and try to move them so that they appear elsewhere in your document.
  2. If you are only interested in the arrows then you could easily hook some different buttons up to the API so that they called scrollBy to do the scrolling [see http://jscrollpane.kelvinluck.com/scroll_to.html ]. Additionally you can hook up to the jsp-scroll-x/y events to mark your homemade arrows as disabled when relevant [see http://jscrollpane.kelvinluck.com/events.html ]. And you would use CSS to hide the "real" scroll bar and arrows.
  3. You could try using javascript to move the elements (e.g. something like $('#myDiv').append($('.jspVerticalBar')); ) - no guarantees this won't have some strange side effects though!

Hope it gives you some ideas. If you want to add this as a feature request on the github issues list then I'll try to look at it in the future (it'll won't be soon though - I'm really busy with client work at the moment).

小帐篷 2024-10-07 10:58:13

由于某种原因,我无法评论 vitch 的答案,但我只是想为来到此页面的任何人记录选项 3 和一些简单的 CSS 调整(主要是将 .jspContainer 上的position:absolute 切换为position:relative)的效果我。

For some reason I can't comment on vitch's answer but I just wanted to document for anyone coming to this page that option 3 and some simple CSS adjustments (the main one being switching position:absolute to position:relative on .jspContainer) worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文