Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1485934

    Dear team,
    on my page below I use on the very top a color section with 1/1 box inside. I need to change the parallax effect of this box: Now it disappears to the very top, but it shall longer be visible at scrolling, i.e. it shall move down. But I did not find a way to realize this. Menu does not offer a reverse movement and +/- are only changing the speed.

    Would be great to know how this can be realized

    thx a lot & best regards Tilman

    #1486090

    Hey Tilman,
    Thank you for your patience, but I don’t understand what you wish to do. Do you want the text to move down as you scroll? Perhaps if you could explain further.

    Best regards,
    Mike

    #1486091

    Hey Mike, exactly. If i scroll down the Text Shall move downwards to in Order to be longer visible.

    Thx a lot & best regards Tilman

    #1486098

    and the parallax speed of -30% is not enough?
    only values less than -100% have that effect you described – but this option does not exist …

    (by the way – a value of -100 means that the column is quasi in fixed position )

    give a unique ID to that Column. Set all your parallax options ( -30% is not enough for you ) and set these setting by child-theme functions.php for that ID:

    function my_custom_all_parallax_settings() {
    ?>
    <script>
    window.addEventListener("DOMContentLoaded", function () {
        const container = document.getElementById('myID1');
    
        if (container) {
            // Create a new JavaScript object with ALL the desired parallax settings
            // You can customize any value here as you need it.
            const newParallaxSettings = {
                "parallax": "bottom_top",       // Standard Parallax
                "parallax_speed": "-150",       // Standard Parallax Speed
    
                "av-desktop-parallax": "bottom_top", // Desktop
                "av-desktop-parallax_speed": "-100",  // Desktop Speed
    
                "av-medium-parallax": "bottom_top",  // Medium Tablet
                "av-medium-parallax_speed": "-50",   // Medium Tablet Speed
    
                // only change those values that you can not set by Enfold Options Dialog
    
                // "av-small-parallax": "no_parallax", 
                // "av-small-parallax_speed": "no_parallax", 
    
                // "av-mini-parallax": "no_parallax", 
                // "av-mini-parallax_speed": "no_parallax" 
            };
    
            // Convert the new object into a JSON string
            const newParallaxData = JSON.stringify(newParallaxSettings);
    
            // Set the new data-parallax attribute
            container.setAttribute('data-parallax', newParallaxData);
    
            console.log('Data attribute for all parallax settings changed successfully!');
            console.log('New data-parallax value:', container.getAttribute('data-parallax'));
        } else {
            console.error('Container with ID "myID1" not found.');
        }
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_all_parallax_settings');

    However, be aware that high parallax speed values may cause the element to “jerk” while scrolling.

    #1486105

    Hi,
    Thanks for your help Guenni007, but in my test it seems that only targeting the ID “#av_section_1” didn’t help, I tried adjusting to const container = document.querySelector('#av_section_1 .av-parallax-object'); to target the text in the parallax but as you pointed out it was jerky for the speed needed.
    With trial and error and AI I found that this javascript & css works well for desktop & mobile and smooths out most all the jerk from the text and background image.
    Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function move_text_in_parallax_down_on_scroll() { ?>
      <script>
      document.addEventListener("DOMContentLoaded", function () {
      const el = document.querySelector("#av_section_1 .av-parallax-object");
      const bg = document.querySelector("#av_section_1 .av-parallax");
    
      if (!el || !bg) return;
    
      const isMobile = window.innerWidth < 768;
    
      const textSpeed = isMobile ? 0.9 : 0.7;
      const bgSpeed = isMobile ? 0.3 : 0.2;
    
      let currentYText = 0;
      let currentYBg = 0;
    
      const updateParallax = () => {
        const scrollY = window.scrollY || window.pageYOffset;
    
        // Text transform
        const targetYText = scrollY * textSpeed;
        currentYText += (targetYText - currentYText) * 0.05;
        el.style.transform = translateY(${currentYText}px);
    
        // Background transform
        const targetYBg = scrollY * bgSpeed;
        currentYBg += (targetYBg - currentYBg) * 0.05;
        bg.style.transform = translateY(${currentYBg}px); // GPU accelerated
    
        requestAnimationFrame(updateParallax);
      };
    
      requestAnimationFrame(updateParallax);
    });
      </script>
      <style>
      #av_section_1 .av-parallax-object {
      position: relative;
      top: 0;
      left: 0;
      will-change: transform;
      backface-visibility: hidden;
      transform: translateZ(0);
    }
    #av_section_1 {
      position: relative;
      overflow: hidden;
    }
    #av_section_1 .av-parallax {
      background-attachment: scroll !important; /* disables fixed scroll handling */
      background-position: center center !important;
      transform: none !important;
      will-change: auto !important;
    }  
      </style>
      <?php
    }
    add_action( 'wp_footer', 'move_text_in_parallax_down_on_scroll', 99 );

    If you are not using a child theme you could use the WP Code plugin then add a new snippet, in the top right corner use the PHP snippet as the code type:
    use wpcode php snippet and activate
    and ensure that it is activated, then add the above code and save.

    Best regards,
    Mike

    #1486129

    as i understood him it is the column not the section – so my way was to give the ID to the column.
    The column has the parallax attribute. And i think he is talking about the parallax effect on element itself – not the background-image of the column. there is no option for that on columns.

    I tested it on an existing testpage of mine ( so the codes there have nothing to do with the solution here ). but see the right column with that image.

    https://webers-testseite.de/8col-flex/
    see what happens when hamburger is active – the direction is then the other way round (+50)

    my fault is that i do not preserve the rest of the existing settings – here a corrected code:

    function my_custom_all_parallax_settings_preserving_others() {
    ?>
    <script>
    window.addEventListener("DOMContentLoaded", function () {
        const container = document.getElementById('myID1');
    
        if (container) {
            // 1. Get the current value of the data-parallax attribute
            const currentParallaxData = container.getAttribute('data-parallax');
    
            // 2. Parse the string into a JavaScript object
            let parallaxObject = {};
            try {
                // Attempt to parse existing data. If it's empty or invalid, start with an empty object.
                parallaxObject = JSON.parse(currentParallaxData || '{}');
            } catch (e) {
                console.error('Error parsing existing data-parallax attribute:', e);
                // If parsing fails, ensure parallaxObject is an empty object to avoid errors
                parallaxObject = {};
            }
    
            // 3. Define the changes you want to apply.
            //    Only the properties listed here will be updated or added.
            //    Existing properties not listed here will be preserved.
            const changesToApply = {
                "parallax": "bottom_top",       // Standard Parallax 
                "parallax_speed": "-150",       // Standard Parallax Speed
    
                "av-desktop-parallax": "bottom_top", // Desktop 
                "av-desktop-parallax_speed": "-100",  // Desktop: Speed
    
                "av-medium-parallax": "bottom_top",  // Medium Tablet
                "av-medium-parallax_speed": "50",   // Medium Tablet Speed
    
                "av-small-parallax": "no_parallax", // Parallax off
                "av-small-parallax_speed": "no_parallax", // no speed needed
    
                "av-mini-parallax": "no_parallax", // Mobil Parallax 
                "av-mini-parallax_speed": "no_parallax" // No Speed needed
                // Do NOT include "parallax-container" here, as we want to preserve its original value
            };
    
            // 4. Merge the changes into the existing parallaxObject.
            //    Object.assign() overwrites existing properties and adds new ones.
            //    Properties in 'parallaxObject' that are NOT in 'changesToApply' will remain untouched.
            Object.assign(parallaxObject, changesToApply);
    
            // 5. Convert the modified object back into a JSON string
            const newParallaxData = JSON.stringify(parallaxObject);
    
            // 6. Set the new value of the data-parallax attribute
            container.setAttribute('data-parallax', newParallaxData);
    
            console.log('Data attribute for parallax settings updated successfully!');
            console.log('New data-parallax value:', container.getAttribute('data-parallax'));
        } else {
            console.error('Container with ID "myID1" not found.');
        }
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_all_parallax_settings_preserving_others');

    btw: on 3. read that comment:

            // 3. Define the changes you want to apply.
            //    Only the properties listed here will be updated or added.
            //    Existing properties not listed here will be preserved.

    so if you only want to influence the desktop parallax speed then only change it in the code above and do not mention the other settings there

    #1486132

    by the way – for color-sections there is a filter to influence the parallax speed of the background-image:
    and : a negative ratio makes no sense.

    function avia_change_parallax_ratio($ratio, $id){ 
      if($id == 'myid'){
        $ratio = "0.3";
        return $ratio;
      }
    }
    add_filter('avf_parallax_speed','avia_change_parallax_ratio', 10, 2);
    #1486189

    Hi Mike,
    i was hoping there is an easy way just to make the columns inside the section move down instead go moving up during the parallax move.

    Did I overlook a simple way to do it?
    Your discussion with another member is for me too much tech talk :-)


    @guenni007
    : thx for your efforts , but -30% does not change the direction at my end, just the speed (as the enfold hints tell). And advanced coding via functions.php is not my business …
    .

    #1486190

    did you see my test page:
    https://webers-testseite.de/8col-flex/
    the colum on the right side – has a -100% – this is as if it is fixed a -150% will have that effect you described.

    I change it for now to 150% in that function: link

    short version with no comments and only with the changing of desktop parallax speed:
    ( Do not forget to set the custom ID: myID1 to the column )

    function my_custom_all_parallax_settings_preserving_others() {
    ?>
    <script>
    window.addEventListener("DOMContentLoaded", function () {
        const container = document.getElementById('myID1');
        if (container) {
            const currentParallaxData = container.getAttribute('data-parallax');
            let parallaxObject = {};
            try {
                parallaxObject = JSON.parse(currentParallaxData || '{}');
            } catch (e) {
                console.error('Error parsing existing data-parallax attribute:', e);
                parallaxObject = {};
            }
            const changesToApply = {
                "av-desktop-parallax": "bottom_top", // Desktop 
                "av-desktop-parallax_speed": "-150",  // Desktop: Speed
            };
            Object.assign(parallaxObject, changesToApply);
            const newParallaxData = JSON.stringify(parallaxObject);
            container.setAttribute('data-parallax', newParallaxData);
        } 
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_all_parallax_settings_preserving_others');
    #1486216

    Hi,


    @oestersund
    did you try the solution that I posted? I tested it on your site and it works.
    I also included the steps on how to add it to your site.

    Best regards,
    Mike

    #1486351

    Hi Mike,
    sorry for delay – yes, thx, this was helpful. topic can be closed.

    cheers, Tilman

    #1486352

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Columns w/ Parallax – Change direction’ is closed to new replies.