orxapi.tools.toscroll
Version:
The TypeScript toScroll tools library for orxapi
65 lines (48 loc) • 1.66 kB
Markdown
[](https://badge.fury.io/js/orxapi.tools.toscroll.svg)
# orxapi.tools.toscroll
The toScroll tools library for orxapi.
## Getting Started
If you haven't used [NodeJs](http://nodejs.org/) before, be sure to have install the LTS version on your desktop ! Check your version with this command:
```shell
node -v
v6.9.2
```
## Installation
```shell
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
```ts
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
```html
<a href="#contentInformation" data-scroll-offset="100">Best price</a>
...
<div id="contentInformation" class="content">
...
</div>
```
## Methods
- **toScroll** Toggle link from data id <br>
- **handleToScroll** Scroll to target position <br>
- **toScrollFromUrl** Scroll to the target form hash into url <br>
- **getPosition** Always return a coordinate object <br>
See docs for more information
*This library was designed to work with ES 5+*
### TODO
- [ ] Add tests
- [ ] Improve the documentation