Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hsnaydd committed Oct 21, 2017
2 parents f5406b8 + 361fd44 commit 9fcb4d8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ Ease function. See [Easing Equations](http://gizma.com/easing/) for more ease fu
```
</details>

<details>
<summary>Back to top</summary>

```js
document.addEventListener('DOMContentLoaded', function () {
const moveTo = new MoveTo();
const triggers = document.getElementsByClassName('js-back-to-top');

for (var i = 0; triggers.length < i; i++) {
moveTo.registerTrigger(triggers[i]);
}
});
```

```html
<a href="#" class="js-back-to-top" data-mt-duration="300">Back to top!</a>
```
</details>

## Development setup

```sh
Expand Down
9 changes: 2 additions & 7 deletions dist/moveTo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* MoveTo - A lightweight scroll animation javascript library without any dependency.
* Version 1.7.0 (01-10-2017 14:12)
* Version 1.7.1 (22-10-2017 02:28)
* Licensed under MIT
* Copyright 2017 Hasan Aydoğdu <hsnaydd@gmail.com>
*/
Expand Down Expand Up @@ -87,7 +87,7 @@ var MoveTo = function () {
// The element to be scrolled
var target = href && href !== '#' ?
document.getElementById(href.substring(1)) :
0;
document.body;
var options = mergeObject(this.options, _getOptionsFromTriggerDom(dom, this.options));

if (typeof callback === 'function') {
Expand Down Expand Up @@ -123,11 +123,6 @@ var MoveTo = function () {
var lastPageYOffset = void 0;
distance -= options.tolerance;

// if distance is `0`, it means to back to the top
if (distance === 0) {
distance -= from;
}

// rAF loop
var loop = function loop(currentTime) {
var currentPageYOffset = window.pageYOffset;
Expand Down
4 changes: 2 additions & 2 deletions dist/moveTo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moveto",
"version": "1.7.0",
"version": "1.7.1",
"description": "A lightweight scroll animation javascript library without any dependency.",
"main": "dist/moveTo.js",
"scripts": {
Expand Down
7 changes: 1 addition & 6 deletions src/moveTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const MoveTo = (() => {
// The element to be scrolled
const target = (href && href !== '#')
? document.getElementById(href.substring(1))
: 0;
: document.body;
const options = mergeObject(this.options, _getOptionsFromTriggerDom(dom, this.options));

if (typeof callback === 'function') {
Expand Down Expand Up @@ -116,11 +116,6 @@ const MoveTo = (() => {
let lastPageYOffset;
distance -= options.tolerance;

// if distance is `0`, it means to back to the top
if (distance === 0) {
distance -= from;
}

// rAF loop
const loop = (currentTime) => {
let currentPageYOffset = window.pageYOffset;
Expand Down

0 comments on commit 9fcb4d8

Please sign in to comment.