Lay Theme Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    Text Color based on current row-background

    General Discussion
    2
    4
    296
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stdhd last edited by

      Hi there,

      I've tried this code to change text based on current row-background and it works for desktop perfect.

      But not on mobile. Can I put the code elsewhere for mobile?

      For testing: I've tried to set Phone Breakpoint to „0“ and it works but not with setting "600“. Is there any easy solution for this?

      var offset = 50;
      var $blackRows;
      var $nav;
      
      Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj){
          $blackRows = jQuery(".blackrow");
          $nav = jQuery("nav");
          $nav.removeClass("white");
      });
      
      jQuery(document).on("scroll", function(){
          $blackRows.each(function(){
              var rect = this.getBoundingClientRect();
              if(rect.top - offset < 0 && rect.bottom - offset > 0){
                  $nav.addClass("white");
                  return false;
              }else{
                  $nav.removeClass("white");
              }
          });
      });
      

      Source: http://laythemeforum.com:4567/topic/699/change-link-color-on-fixed-nav-based-on-current-row-background

      Thanks!

      1 Reply Last reply Reply Quote 0
      • mariusjopen
        mariusjopen Global Moderator last edited by

        Hi @stdhd
        did you try to put it into the other Custom HTML Fields?

        Can you post a link to your website?

        All the best!

        Marius

        www.mariusjopen.world

        1 Reply Last reply Reply Quote 0
        • S
          stdhd last edited by

          Thank you Marius. Yes tried different Custom HTML Fields. Desktop works fine in all fields. I've send you a chat message with development link.

          1 Reply Last reply Reply Quote 0
          • mariusjopen
            mariusjopen Global Moderator last edited by

            Hehe :-)
            When you add the class via jQuery you add it to the navigation.
            The navigation does not exist on mobile. There we use a different navigation.

            In general it is good to add this kind of classed to the body.
            Then you can use them for all the elements you like.

            I hope that helps!

            Best!

            Marius

            www.mariusjopen.world

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Before you post

            Use the Search Feature. Maybe there is already a solution to your issue.

            1. Update Lay Theme and all Lay Theme Addons
            2. Disable all Plugins
            3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
            4. Now see if your problem solved itself
            5. Go here, see if your problem is listed here:
            Troubleshooting

            When you post:
            1. Post a link to where the problem is
            2. If the problem is difficult to explain, post screenshots / link to a video to explain it

            Thanks!

            Online Users

            Z
            S
            K

            Recent Topics

            • M

              komische boxen auf der Website

            • S

              Theme crashed - because of Polylang?

            • J

              Split Screen just on front page / subpages without the split?

            laytheme.com