Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed rounding issue #455

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/locomotive-scroll.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! locomotive-scroll v4.1.3 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
/*! locomotive-scroll v4.1.4 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
html.has-scroll-smooth {
overflow: hidden; }

Expand Down
10 changes: 6 additions & 4 deletions dist/locomotive-scroll.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* locomotive-scroll v4.1.3 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
/* locomotive-scroll v4.1.4 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
Expand Down Expand Up @@ -1277,7 +1277,7 @@ var _default$1 = /*#__PURE__*/function (_Core) {
*
* @param Available options :
* target {node, string, "top", "bottom", int} - The DOM element we want to scroll to
* options {object} - Options object for additionnal settings.
* options {object} - Options object for additional settings.
* @return {void}
*/

Expand Down Expand Up @@ -1319,7 +1319,9 @@ var _default$1 = /*#__PURE__*/function (_Core) {
}

var isTargetReached = function isTargetReached() {
return parseInt(window.pageYOffset) === parseInt(offset);
var _offset = Math.round(offset);

return Math.round(window.pageYOffset) < _offset + 2 && Math.round(window.pageYOffset) > _offset - 2;
};

if (callback) {
Expand Down Expand Up @@ -2862,7 +2864,7 @@ var _default$2 = /*#__PURE__*/function (_Core) {
*
* @param Available options :
* target {node, string, "top", "bottom", int} - The DOM element we want to scroll to
* options {object} - Options object for additionnal settings.
* options {object} - Options object for additional settings.
* @return {void}
*/

Expand Down
10 changes: 6 additions & 4 deletions dist/locomotive-scroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* locomotive-scroll v4.1.3 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
/* locomotive-scroll v4.1.4 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
Expand Down Expand Up @@ -1283,7 +1283,7 @@
*
* @param Available options :
* target {node, string, "top", "bottom", int} - The DOM element we want to scroll to
* options {object} - Options object for additionnal settings.
* options {object} - Options object for additional settings.
* @return {void}
*/

Expand Down Expand Up @@ -1325,7 +1325,9 @@
}

var isTargetReached = function isTargetReached() {
return parseInt(window.pageYOffset) === parseInt(offset);
var _offset = Math.round(offset);

return Math.round(window.pageYOffset) < _offset + 2 && Math.round(window.pageYOffset) > _offset - 2;
};

if (callback) {
Expand Down Expand Up @@ -2868,7 +2870,7 @@
*
* @param Available options :
* target {node, string, "top", "bottom", int} - The DOM element we want to scroll to
* options {object} - Options object for additionnal settings.
* options {object} - Options object for additional settings.
* @return {void}
*/

Expand Down
2 changes: 1 addition & 1 deletion dist/locomotive-scroll.min.css

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

2 changes: 1 addition & 1 deletion dist/locomotive-scroll.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/scripts/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/styles/main.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion src/scripts/Native.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ export default class extends Core {
}

const isTargetReached = () => {
return parseInt(window.pageYOffset) === parseInt(offset);
const _offset = Math.round(offset);
return (
Math.round(window.pageYOffset) < _offset + 2 &&
Math.round(window.pageYOffset) > _offset - 2
);
};
if (callback) {
if (isTargetReached()) {
Expand Down