Comparing version 1.7.0 to 1.7.1
/*! | ||
* 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 | ||
@@ -90,3 +90,3 @@ * Copyright 2017 Hasan Aydoğdu <hsnaydd@gmail.com> | ||
document.getElementById(href.substring(1)) : | ||
0; | ||
document.body; | ||
var options = mergeObject(this.options, _getOptionsFromTriggerDom(dom, this.options)); | ||
@@ -127,7 +127,2 @@ | ||
// if distance is `0`, it means to back to the top | ||
if (distance === 0) { | ||
distance -= from; | ||
} | ||
// rAF loop | ||
@@ -134,0 +129,0 @@ var loop = function loop(currentTime) { |
/*! | ||
* 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 | ||
@@ -8,2 +8,2 @@ * Copyright 2017 Hasan Aydoğdu <hsnaydd@gmail.com> | ||
"use strict";var MoveTo=function(){function t(t,e,n,o){return t/=o,t--,-n*(t*t*t*t-1)+e}function e(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e]}),Object.keys(e).forEach(function(t){n[t]=e[t]}),n}function n(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}function o(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options=e(r,n),this.easeFunctions=e({easeOutQuart:t},o)}function i(t,e){var o={};return Object.keys(e).forEach(function(e){var i=t.getAttribute("data-mt-"+n(e));i&&(o[e]=isNaN(i)?i:parseInt(i,10))}),o}var r={tolerance:0,duration:800,easing:"easeOutQuart",callback:function(){}};return o.prototype.registerTrigger=function(t,n){var o=this;if(t){var r=t.getAttribute("href")||t.getAttribute("data-target"),a=r&&"#"!==r?document.getElementById(r.substring(1)):0,u=e(this.options,i(t,this.options));"function"==typeof n&&(u.callback=n);var c=function(t){t.preventDefault(),o.move(a,u)};return t.addEventListener("click",c,!1),function(){return t.removeEventListener("click",c,!1)}}},o.prototype.move=function(t){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===t||t){o=e(this.options,o);var i="number"==typeof t?t:t.getBoundingClientRect().top,r=window.pageYOffset,a=null,u=void 0;i-=o.tolerance,0===i&&(i-=r);var c=function e(c){var s=window.pageYOffset;a||(a=c-1);var f=c-a;if(u&&(i>0&&u>s||i<0&&u<s))return o.callback(t);u=s;var v=n.easeFunctions[o.easing](f,r,i,o.duration);window.scroll(0,v),f<o.duration?window.requestAnimationFrame(e):(window.scroll(0,i+r),o.callback(t))};window.requestAnimationFrame(c)}},o.prototype.addEaseFunction=function(t,e){this.easeFunctions[t]=e},o}();"undefined"!=typeof module?module.exports=MoveTo:window.MoveTo=MoveTo; | ||
"use strict";var MoveTo=function(){function t(t,e,n,o){return t/=o,t--,-n*(t*t*t*t-1)+e}function e(t,e){var n={};return Object.keys(t).forEach(function(e){n[e]=t[e]}),Object.keys(e).forEach(function(t){n[t]=e[t]}),n}function n(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}function o(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options=e(r,n),this.easeFunctions=e({easeOutQuart:t},o)}function i(t,e){var o={};return Object.keys(e).forEach(function(e){var i=t.getAttribute("data-mt-"+n(e));i&&(o[e]=isNaN(i)?i:parseInt(i,10))}),o}var r={tolerance:0,duration:800,easing:"easeOutQuart",callback:function(){}};return o.prototype.registerTrigger=function(t,n){var o=this;if(t){var r=t.getAttribute("href")||t.getAttribute("data-target"),a=r&&"#"!==r?document.getElementById(r.substring(1)):document.body,u=e(this.options,i(t,this.options));"function"==typeof n&&(u.callback=n);var c=function(t){t.preventDefault(),o.move(a,u)};return t.addEventListener("click",c,!1),function(){return t.removeEventListener("click",c,!1)}}},o.prototype.move=function(t){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===t||t){o=e(this.options,o);var i="number"==typeof t?t:t.getBoundingClientRect().top,r=window.pageYOffset,a=null,u=void 0;i-=o.tolerance;var c=function e(c){var s=window.pageYOffset;a||(a=c-1);var f=c-a;if(u&&(i>0&&u>s||i<0&&u<s))return o.callback(t);u=s;var d=n.easeFunctions[o.easing](f,r,i,o.duration);window.scroll(0,d),f<o.duration?window.requestAnimationFrame(e):(window.scroll(0,i+r),o.callback(t))};window.requestAnimationFrame(c)}},o.prototype.addEaseFunction=function(t,e){this.easeFunctions[t]=e},o}();"undefined"!=typeof module?module.exports=MoveTo:window.MoveTo=MoveTo; |
{ | ||
"name": "moveto", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "A lightweight scroll animation javascript library without any dependency.", | ||
@@ -5,0 +5,0 @@ "main": "dist/moveTo.js", |
@@ -194,2 +194,21 @@ # MoveTo [![npm version](https://badge.fury.io/js/moveto.svg)](https://badge.fury.io/js/moveto) [![Bower version](https://badge.fury.io/bo/moveTo.svg)](https://badge.fury.io/bo/moveTo) [![Build Status](https://travis-ci.org/hsnaydd/moveTo.svg?branch=master)](https://travis-ci.org/hsnaydd/moveTo.js) | ||
<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 | ||
@@ -196,0 +215,0 @@ |
@@ -83,3 +83,3 @@ | ||
? document.getElementById(href.substring(1)) | ||
: 0; | ||
: document.body; | ||
const options = mergeObject(this.options, _getOptionsFromTriggerDom(dom, this.options)); | ||
@@ -120,7 +120,2 @@ | ||
// if distance is `0`, it means to back to the top | ||
if (distance === 0) { | ||
distance -= from; | ||
} | ||
// rAF loop | ||
@@ -127,0 +122,0 @@ const loop = (currentTime) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
214569
18
652
252