horizontal scroll, detecting scroll position relative to anchors

后端 未结 6 965
予麋鹿
予麋鹿 2021-01-12 19:50

Ok, I\'m building a horizontal scroll website for a photographer. We have some really nice wireframes done and I\'m looking to create a neat effect where it highlights the

6条回答
  •  青春惊慌失措
    2021-01-12 20:23

    you'll have to synthesize two figures.

    a - you can find the position of the scroll using

     oDiv.scrollLeft
    

    b - once pictures are loaded - you can sum the sizes of the pictures (or if you set it mannually - you don't even have to wait for them to load.

    oImg.style.width
    

    Assuming you give the same spacing between the pictures - the math becomes obvious.

    It's a little JavaScript, that's all :)

提交回复
热议问题