Jump to content
Sign in to follow this  

moving object between two preset location on scrolling

Recommended Posts

Hi w3 Community


i want to learn how to replicate this effect on the main screen of this website https://overv.io/

  • The traget(booklets) starts off somewhere fixed and translate/rotates towards 0
  • once it's reached it's original location, scrolling further down won't change any location
  • scrolling back up with move the items back towards the location it stated.

Here's something which i think it should look like..

window.onscroll = function() {var speed = 1; //this should be adapted to the height of divvar startdeg = 130; //var startx = 300;var starty =-300;var scroll = $(window).scrollTop(); //using scrolling as variablevar deg = (startdeg - scroll) / speed;var translatex = startx - scroll/ speed;var translatey = starty - scroll/ speed;//Here should be some conditioner or maybe a do-while loop to stop transforming once it reached it's original location?$(".logo").css({"transform": "translate("translatex+"px,"translatey+"px) rotate("+deg+"deg)",}); };



PS: I'm fairly basic with javascript,jquery though i can fully understand the code presented. Thanks a lot!!

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...