Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript position fixed only on scroll X

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #277523
    valec
    Participant

    hello:

    any idea on how to make a div fixed only by the scroll x not y ?

    thanks!

    #277577
    Shikkediel
    Participant

    The example from your previous topic seems to work fine…

    codepen.io/anon/pen/WaENbX

    Edit – I overlooked the issue with IE when I posted this. And no more IE11 support for JSFiddle or Codepen apparently…

    #277578
    Shikkediel
    Participant

    You could try if this is any smoother (doesn’t require repaints):

    $(window).scroll(function() {
    
      $('#header').css({
        transform: 'translateX(' + $(this).scrollLeft() + 'px)'
      });
    });
    
    #277580
    Shikkediel
    Participant

    Doesn’t look too smooth on Firefox. Here’s another approach (logic is likely up for some revision as is usually the case with these things):

    codepen.io/anon/pen/XxaXzN

    Seems to work well, can’t imagine IE giving any issues.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.