question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$scroll target scroll offset not always an Integer

See original GitHub issue

Scroll offset calculation sometimes gives us a value with a fraction ex: 8245.125 target = target.getBoundingClientRect().top + window.pageYOffset

then, it fails this check: if (Number.isInteger(target)) {

continues to: if (typeof target !== 'object')

and throws Unsupported $scroll target error

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
SimoTodcommented, Nov 29, 2020

Good catch. I think we can simply use Math.floor(…) to round down the result. Are you happy to send a PR? Otherwise I can have a look tomorrow.

0reactions
mikestempiencommented, Nov 30, 2020

Yep, works in my case, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

offsetting an html anchor to adjust for fixed header [duplicate]
Sometimes it works, some other clicks it doesn't (scroll position stays at the anchor position). I am totally out of ideas what could...
Read more >
Element.scrollTop - Web APIs | MDN
The Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically.
Read more >
locomotivemtl/locomotive-scroll: Detection of elements in ...
Detection of elements in viewport & smooth scrolling with parallax. ... offset (integer) : Defines an offset from your target.
Read more >
Smooth Scrolling | CSS-Tricks
Here's the code to perform a smooth page scroll to an anchor on the same page. It has some logic built in to...
Read more >
.scrollLeft() | jQuery API Documentation
The horizontal scroll position is the same as the number of pixels that are hidden from view to the left of the scrollable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found