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

[Bug Report] GoTo element with offset above top of page locks scrolling #3384

Closed
BenShelton opened this issue Feb 25, 2018 · 6 comments · Fixed by #3542
Closed

[Bug Report] GoTo element with offset above top of page locks scrolling #3384

BenShelton opened this issue Feb 25, 2018 · 6 comments · Fixed by #3542
Assignees
Labels
T: bug Functionality that does not work as intended/expected

Comments

@BenShelton
Copy link

Versions and Environment

Vuetify: 1.0.3
Vue: 2.5.13
Browsers: Chrome 64.0.3282.167
OS: Mac OS 10.13.3

Steps to reproduce

  • Have a page that can scroll
  • Have an element near the top of the page that you want to scroll to
  • Use $vuetify.goTo('#element-near-top', { offset: -100 }) where the offset will attempt to scroll past the top of the page
  • Try to scroll down

Expected Behavior

Page will scroll down

Actual Behavior

Page keeps bouncing back to the top preventing you from scrolling

Reproduction Link

https://codepen.io/BenShelton/pen/jZeNMg

@BenShelton
Copy link
Author

BenShelton commented Feb 25, 2018

It also seems just specifying a negative scroll value has the same effect, for example: $vuetify.goTo(-100)

@johnleider johnleider added the T: bug Functionality that does not work as intended/expected label Feb 26, 2018
@IPRIT
Copy link

IPRIT commented Feb 27, 2018

offsetTop for h1-6 also doesn't work properly.

@ayush987goyal
Copy link

Also, it does not work in the production build. Using it with @vue/cli@3.0.0-beta.2 and vuetify@1.0.4

@siloam
Copy link

siloam commented Mar 11, 2018

Is there any solution for this bug? It practically makes scrolling impossible with goTo method.

@BenShelton
Copy link
Author

I've created a PR to possibly fix this issue. In the meantime the best thing to do is make sure whatever you pass to goTo will not result in a negative number, so do the calculation beforehand:

let pos = 
  element.offsetTop // if using an element
  VueComponent.$el.offsetTop // if using a Vue component
  document.querySelector('#element-near-top').offsetTop // if using a string
  20 // if using a number

const offset = -100
const pos = Math.max(pos + offset, 0)
this.$vuetify.goTo(pos)

@lock
Copy link

lock bot commented Apr 14, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please direct any non-bug questions to our Discord

@lock lock bot locked as resolved and limited conversation to collaborators Apr 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants