Coder Social home page Coder Social logo

negative margin-top about skrollr-menu HOT 7 CLOSED

prinzhorn avatar prinzhorn commented on September 16, 2024
negative margin-top

from skrollr-menu.

Comments (7)

Prinzhorn avatar Prinzhorn commented on September 16, 2024

but the hashlinks are not working properly.

Well, what are they doing? I can't help you without an example/demo page.

from skrollr-menu.

xbogdan avatar xbogdan commented on September 16, 2024

I created a repo: https://github.com/xbogdan/skrollrmenu
the only thing modified there is the line 30 which has data-0="margin-top:0px" data-1000="margin-top:-500px".
My issue is that the hashlink doesn t gets where the h1 is after scroll.

from skrollr-menu.

Prinzhorn avatar Prinzhorn commented on September 16, 2024

I recommend reading the documentation (again). It's very short but basically describes what you're asking for https://github.com/Prinzhorn/skrollr-menu#documentation

from skrollr-menu.

xbogdan avatar xbogdan commented on September 16, 2024

I did read it at least 10 times but I'm missing something. I don t understand what "scale" does.

from skrollr-menu.

Prinzhorn avatar Prinzhorn commented on September 16, 2024

Quoting relevant parts

If you animate top, margin-top or anything that moves the element up/down, the browser won't be able to jump to the correct position and you may end up somewhere else

...

in order to fix the problem with the wrong offset, you are able to specify the target scroll position right at the link, e.g. <a href="#section-about" data-menu-top="500">About</a>

Also in your case you could just specify the 500px as offset https://github.com/Prinzhorn/skrollr-menu#offsets

<h1 id="awesome" data-menu-offset="-500" data-0='margin-top:0px' data-1000="margin-top: -500px">Awesome</h1>

from skrollr-menu.

xbogdan avatar xbogdan commented on September 16, 2024

Yeah my mistake, I thought the plugin calculates where the "container" will be after scroll. The problem is that my website has only one page which is split in 9 containers (one above other) and each container has height set as the window height (depending on monitor resolution etc). So sometimes you scroll more or less to get where you want.

from skrollr-menu.

Prinzhorn avatar Prinzhorn commented on September 16, 2024

So sometimes you scroll more or less to get where you want.

But if you always animate the same margin, then it should work fine. Also you can use percentage offsets on the link

<a href="#section-2" data-menu-top="100p">Start of the second section</a>

from skrollr-menu.

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.