Git Product home page Git Product logo

Comments (3)

individual11 avatar individual11 commented on June 3, 2024

You mean if you go to a different page, it doesn't scroll? 2 things to check:

  1. Does that page have the scroll plugin included?
  2. Are you waiting for the page to load before you trigger the scrolling?

from scroll-to.

deigolocco avatar deigolocco commented on June 3, 2024

Yes, a different page in the same site.
1- Yes.
2- I don't know. How I do that?

from scroll-to.

individual11 avatar individual11 commented on June 3, 2024

Ok, so there is a shortcut for document ready in jQuery:

$(function(){
///the document is ready now
});

Do you have the example running somewhere I can see? I bet when the page loads, it jumps to that anchor right? We need to stop that first.

$(function(){
   if (location.hash) {
    window.scrollTo(0, 0);
  }
});

And then we will want to scroll down to it.

$(function(){
   //setup scrollTo, where $(el) is the element you want to click on
   $(el).scrollTo();
   //now check if there is hash in the url
   if (location.hash) {
    window.scrollTo(0, 0);
    //now trigger the event we need based on the hash that gets passed from the url
    $(location.hash).trigger("click");
  }
});

I haven't tested this code, and it's making a few assumptions, so let me know if it works.

from scroll-to.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.