GithubHelp home page GithubHelp logo

Comments (6)

 avatar commented on August 11, 2024 9

I was able to fix this by including this function:

jumpTo = (obj) => {
    scrollTo({
        top: document.querySelector(obj).offsetTop,
        left: 0,
        behavior: 'smooth'
    });
    window.location = `${obj}`;
};

And modifying the "a" tag like so:

<a onclick="jumpTo('#home')" class="class-name" href="#home">Link Text</a>

However, with this solution, it is not possible to send a link and directly go to a specific spot in the page unless you use a separate function like this one:

//make sure luxy is initiated before this function is called
window.addEventListener("load", () => {
    if(window.location.href.split("#")[1] != null) {
            jumpTo(`#${window.location.href.split("#")[1]}`);
    };
});

Note: I haven't tested this on my site as it has a load animation which doesn't let the user scroll.

from luxy.js.

packytagliaferro avatar packytagliaferro commented on August 11, 2024 1

I am also having this issue. I have the site wrapped in one div with `id="luxy". The demo site does appear to work though if I provide a hash in the url with an ID though.

from luxy.js.

ArnaudVerpouckeDeveloper avatar ArnaudVerpouckeDeveloper commented on August 11, 2024

I experience exactly the same problem. The exact same problem occurs also with another library 'butter.js', which does the same (smooth/ease scrolling).

Only disabling the plugin makes the on-page-anchor tags work. But having both, does not seem to be a possibility.

Details: when you click on an anchor tag which is linked to an id on the same page, nothing happens. Only the url changes, but the position remains the same.

from luxy.js.

FelixLttks avatar FelixLttks commented on August 11, 2024

I was able to fix this by including this function:

jumpTo = (obj) => {
    scrollTo({
        top: document.querySelector(obj).offsetTop,
        left: 0,
        behavior: 'smooth'
    });
    window.location = `${obj}`;
};

And modifying the "a" tag like so:

<a onclick="jumpTo('#home')" class="class-name" href="#home">Link Text</a>

However, with this solution, it is not possible to send a link and directly go to a specific spot in the page unless you use a separate function like this one:

//make sure luxy is initiated before this function is called
window.addEventListener("load", () => {
    if(window.location.href.split("#")[1] != null) {
            jumpTo(`#${window.location.href.split("#")[1]}`);
    };
});

Note: I haven't tested this on my site as it has a load animation which doesn't let the user scroll.

true hero

from luxy.js.

haroldao avatar haroldao commented on August 11, 2024

I was able to fix this by including this function:

jumpTo = (obj) => {
    scrollTo({
        top: document.querySelector(obj).offsetTop,
        left: 0,
        behavior: 'smooth'
    });
    window.location = `${obj}`;
};

And modifying the "a" tag like so:

<a onclick="jumpTo('#home')" class="class-name" href="#home">Link Text</a>

However, with this solution, it is not possible to send a link and directly go to a specific spot in the page unless you use a separate function like this one:

//make sure luxy is initiated before this function is called
window.addEventListener("load", () => {
    if(window.location.href.split("#")[1] != null) {
            jumpTo(`#${window.location.href.split("#")[1]}`);
    };
});

Note: I haven't tested this on my site as it has a load animation which doesn't let the user scroll.

ty :)

from luxy.js.

TheElegantCoding avatar TheElegantCoding commented on August 11, 2024

This is because the library adds a div with position fixed to all the page, a fixed element don't scroll and that's why you can't scroll with an anchor you have to specify the translate position you want to go

from luxy.js.

Related Issues (20)

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.