Jump to content

scrollTop javascript function help

Recommended Posts

so im using the code below to create a scroll for some text that.  it works well for the first text block but I need to use it for two others that start further down the page and thats where I am having a problem.   How do you change the starting position?  when I change "top" in the if/else functions of the javascript - it doesnt work.  I also changed the top position of the CSS.    Not sure what to really do .   Also is it possible to have this javascript only work within a section of the page by using the section ID?

I have the javascript and the css that is making that block vertical.  

 

<script>
var windw = this;

$.fn.followTo = function(pos) {
  var $this = this,
    $window = $(windw);

  $window.scroll(function(e) {
    if ($window.scrollTop() > pos) {
      $this.css({
        position: 'absolute',
        top: pos
      });
    } else {
      $this.css({
        position: 'fixed',
        top: 0
      });
    }
  });
};

$('.sidetwo').followTo(400);
  
</script>
<style>
p.sidetwo{
  top: 600px !important;
  writing-mode: vertical-lr !important; 
  text-orientation: upright !important;
  letter-spacing:25px; 
  color:white; 
  font-size:35px; 
  font-family:lato;
}
</style>

 

Link to comment
  • Replies 3
  • Views 236
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Please post the URL for a page on your site where we can see your issue.

A link to the backend of the your site won’t work for us, i.e. a url that contains /config/.

Please set up a site-wide password, if your site is not public and you've not already done so.

Post the password here.

Adding a site-wide password does not allow anyone to alter your site. It only allows those with the password to see your site.

Please read the site-wide password and how to share a link documentation to understand how they work.

We can then take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
On 12/10/2022 at 5:21 PM, creedon said:

Please post the URL for a page on your site where we can see your issue.

A link to the backend of the your site won’t work for us, i.e. a url that contains /config/.

Please set up a site-wide password, if your site is not public and you've not already done so.

Post the password here.

Adding a site-wide password does not allow anyone to alter your site. It only allows those with the password to see your site.

Please read the site-wide password and how to share a link documentation to understand how they work.

We can then take a look at your issue.

https://blueberry-carrot-xawg.squarespace.com/selected

PW codeblock

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.