orxapi.tools.toscroll
The toScroll tools library for orxapi.
Getting Started
If you haven't used NodeJs before, be sure to have install the LTS version on your desktop ! Check your version with this command:
node -v
v6.9.2
Installation
npm install orxapi.tools.toscroll --save-dev
This library is written in TypeScript, but you can use JavaScript. It requires jQuery 2+ to be used.
Usage
TypeScript code
import * as $ from "jquery";
import { toScroll, handleToScroll } from "orxapi.tools.toscroll";
// Scroll to top page
toScroll({
target: $("body"),
duration: 300
});
// Scroll to target position, initalize with data, see the HTML code
$(".link").on("click.toggleLink", handleToScroll);
// Return the position of contentInformation object if exist
// or the coordinate object with top and left value at 0
const topInfo = getPostion($("#contentInformation")).top
HTML code
<a href="#contentInformation" data-scroll-offset="100">Best price</a>
...
<div id="contentInformation" class="content">
...
</div>
Methods
-
toScroll Toggle link from data id
-
handleToScroll Scroll to target position
-
toScrollFromUrl Scroll to the target form hash into url
-
getPosition Always return a coordinate object
See docs for more information
This library was designed to work with ES 5+
TODO
- [ ] Add tests
- [ ] Improve the documentation