api.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>jScrollPane - API documentation</title>
  6. <!-- styles specific to demo site -->
  7. <link type="text/css" href="style/demo.css" rel="stylesheet" media="all" />
  8. <!-- latest jQuery direct from google's CDN -->
  9. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  10. <!-- scripts specific to this demo site -->
  11. <script type="text/javascript" src="script/demo.js"></script>
  12. </head>
  13. <body>
  14. <div id="top-nav">
  15. <img src="image/logo.png" width="196" height="69" alt="jScrollPane">
  16. <ul>
  17. <li><a href="index.html">Home</a></li>
  18. <li><a href="index.html#examples">Examples</a></li>
  19. <li><a href="index.html#themes">Themes</a></li>
  20. <li><a href="index.html#usage">How to use</a></li>
  21. <li><a href="faqs.html">FAQs</a></li>
  22. <li><a href="known_issues.html">Known issues</a></li>
  23. <li><a href="index.html#support">Support</a></li>
  24. <li><a href="index.html#download">Download</a></li>
  25. </ul>
  26. </div>
  27. <div id="container">
  28. <h1>jScrollPane - API documentation</h1>
  29. <p>
  30. This page shows how you can use the jScrollPane API (in addition to the <a href="settings.html">
  31. settings object</a> and the <a href="events.html">events</a> which are dispatched) to update your
  32. jScrollPane after it's has been initially created.
  33. </p>
  34. <p>
  35. To get a reference to the API for a particular scrollpane you will need to access the 'jsp' variable in
  36. the <em>data</em> of the element you applied jScrollPane to. e.g.
  37. </p>
  38. <pre>var element = $('#my-element').jScrollPane({/* ...settings... */});
  39. var api = element.data('jsp');</pre>
  40. <p>
  41. Once you have a reference to the API you can call any of the following methods on it:
  42. </p>
  43. <h2 id="reinitialise">reinitialise(s)</h2>
  44. <p>
  45. Reinitialises the scroll pane (if it's internal dimensions have changed since the last time it
  46. was initialised). The settings object which is passed in will override any settings from the
  47. previous time it was initialised - if you don't pass any settings then the ones from the previous
  48. initialisation will be used.
  49. </p>
  50. <h2 id="scrollToElement">scrollToElement(ele, stickToTop, animate)</h2>
  51. <p>
  52. Scrolls the specified element (a jQuery object, DOM node or jQuery selector string) into view so
  53. that it can be seen within the viewport. If stickToTop is true then the element will appear at
  54. the top of the viewport, if it is false then the viewport will scroll as little as possible to
  55. show the element. You can also specify if you want animation to occur. If you don't provide this
  56. argument then the animateScroll value from the settings object is used instead.
  57. </p>
  58. <h2 id="scrollTo">scrollTo(destX, destY, animate)</h2>
  59. <p>
  60. Scrolls the pane so that the specified co-ordinates within the content are at the top left
  61. of the viewport. animate is optional and if not passed then the value of animateScroll from
  62. the settings object this jScrollPane was initialised with is used.
  63. </p>
  64. <h2 id="scrollToX">scrollToX(destX, animate)</h2>
  65. <p>
  66. Scrolls the pane so that the specified co-ordinate within the content is at the left of the
  67. viewport. animate is optional and if not passed then the value of animateScroll from the settings
  68. object this jScrollPane was initialised with is used.
  69. </p>
  70. <h2 id="scrollToY">scrollToY(destY, animate)</h2>
  71. <p>
  72. Scrolls the pane so that the specified co-ordinate within the content is at the top of the
  73. viewport. animate is optional and if not passed then the value of animateScroll from the settings
  74. object this jScrollPane was initialised with is used.
  75. </p>
  76. <h2 id="scrollToPercentX">scrollToPercentX(destPercentX, animate)</h2>
  77. <p>
  78. Scrolls the pane to the specified percentage of its maximum horizontal scroll position. animate
  79. is optional and if not passed then the value of animateScroll from the settings object this
  80. jScrollPane was initialised with is used.
  81. </p>
  82. <h2 id="scrollToPercentY">scrollToPercentY(destPercentY, animate)</h2>
  83. <p>
  84. Scrolls the pane to the specified percentage of its maximum vertical scroll position. animate
  85. is optional and if not passed then the value of animateScroll from the settings object this
  86. jScrollPane was initialised with is used.
  87. </p>
  88. <h2 id="scrollBy">scrollBy(deltaX, deltaY, animate)</h2>
  89. <p>
  90. Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
  91. the value of animateScroll from the settings object this jScrollPane was initialised with is used.
  92. </p>
  93. <h2 id="scrollByX">scrollByX(deltaX, animate)</h2>
  94. <p>
  95. Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
  96. the value of animateScroll from the settings object this jScrollPane was initialised with is used.
  97. </p>
  98. <h2 id="scrollByY">scrollByY(deltaY, animate)</h2>
  99. <p>
  100. Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
  101. the value of animateScroll from the settings object this jScrollPane was initialised with is used.
  102. </p>
  103. <h2 id="positionDragX">positionDragX(x, animate)</h2>
  104. <p>
  105. Positions the horizontal drag at the specified x position (and updates the viewport to reflect
  106. this). animate is optional and if not passed then the value of animateScroll from the settings
  107. object this jScrollPane was initialised with is used.
  108. </p>
  109. <h2 id="positionDragY">positionDragY(y, animate)</h2>
  110. <p>
  111. Positions the vertical drag at the specified y position (and updates the viewport to reflect
  112. this). animate is optional and if not passed then the value of animateScroll from the settings
  113. object this jScrollPane was initialised with is used.
  114. </p>
  115. <h2 id="animate">animate(ele, prop, value, stepCallback)</h2>
  116. <p>
  117. This method is called when jScrollPane is trying to animate to a new position. You can override
  118. it if you want to provide advanced animation functionality. It is passed the following arguments:
  119. </p>
  120. <ul class="link-list">
  121. <li><strong>ele</strong> - the element whose position is being animated</li>
  122. <li><strong>prop</strong> - the property that is being animated</li>
  123. <li><strong>value</strong> - the value it's being animated to</li>
  124. <li><strong>stepCallback</strong> - a function that you must execute each time you update the value of the property</li>
  125. </ul>
  126. <p>
  127. You can use the default implementation (see <a href="script/jquery.jscrollpane.js">sourcecode</a>) as a
  128. starting point for your own implementation.
  129. </p>
  130. <h2 id="getContentPositionX">getContentPositionX()</h2>
  131. <p>
  132. Returns the current x position of the viewport with regards to the content pane.
  133. </p>
  134. <h2 id="getContentPositionY">getContentPositionY()</h2>
  135. <p>
  136. Returns the current y position of the viewport with regards to the content pane.
  137. </p>
  138. <h2 id="getContentWidth">getContentWidth()</h2>
  139. <p>
  140. Returns the width of the content within the scroll pane.
  141. </p>
  142. <h2 id="getContentHeight">getContentHeight()</h2>
  143. <p>
  144. Returns the height of the content within the scroll pane.
  145. </p>
  146. <h2 id="getIsScrollableH">getIsScrollableH()</h2>
  147. <p>
  148. Returns whether or not this scrollpane has a horizontal scrollbar.
  149. </p>
  150. <h2 id="getPercentScrolledX">getPercentScrolledX()</h2>
  151. <p>
  152. Returns the horizontal position of the viewport within the pane content.
  153. </p>
  154. <h2 id="getPercentScrolledY">getPercentScrolledY()</h2>
  155. <p>
  156. Returns the vertical position of the viewport within the pane content.
  157. </p>
  158. <h2 id="getIsScrollableV">getIsScrollableV()</h2>
  159. <p>
  160. Returns whether or not this scrollpane has a vertical scrollbar.
  161. </p>
  162. <h2 id="getContentPane">getContentPane()</h2>
  163. <p>
  164. Gets a reference to the content pane. It is important that you use this method if you want to
  165. edit the content of your jScrollPane as if you access the element directly then you may have some
  166. problems (as your original element has had additional elements for the scrollbars etc added into
  167. it).
  168. </p>
  169. <h2 id="scrollToBottom">scrollToBottom(animate)</h2>
  170. <p>
  171. Scrolls this jScrollPane down as far as it can currently scroll. If animate isn't passed then the
  172. animateScroll value from settings is used instead.
  173. </p>
  174. <h2 id="hijackInternalLinks">hijackInternalLinks()</h2>
  175. <p>
  176. Hijacks the links on the page which link to content inside the scrollpane. If you have changed
  177. the content of your page (e.g. via AJAX) and want to make sure any new anchor links to the
  178. contents of your scroll pane will work then call this function.
  179. </p>
  180. <h2 id="destroy">destroy()</h2>
  181. <p>
  182. Destroys the jScrollPane on the instance matching this API object and restores the browser's
  183. default behaviour. <a href="destroy.html">Example</a>.
  184. </p>
  185. </div>
  186. </body>
  187. </html>