Tagged: 

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

    Dear Kriesi Team,
    i tried a few things but the Snap Scroll JQUERY does not work on my website.
    The snap-scroll.js is loading in the header and the div sections have the right class but it’s not working.

    Maybe you got a solution?
    The link is in the private content.

    Thanks in advance and best regards!
    Jasper

    #1397259

    Hey Jasper_1,

    Thank you for the inquiry.

    How did you load or initialize the script? Did you use the wp_enqueue_script function?

    // https://developer.wordpress.org/reference/functions/wp_enqueue_script/

    Best regards,
    Ismael

    #1397282

    Hi Ismael,
    thank yo for the quick response.

    I use a child theme and the script is loaded in the functions.php like this:

    // Register and enqueue scripts
    function my_custom_scripts() {
    wp_enqueue_script(
    ‘custom-script’,
    get_stylesheet_directory_uri() . ‘/js/snap-scroll.js’,
    array( ‘jquery’ )
    );
    }

    add_action( ‘wp_enqueue_scripts’, ‘my_custom_scripts’ );

    Best regards,
    Jasper

    #1397382

    Hi,

    We are not familiar with the script unfortunately, and we are not really sure what it does. How did you initialize it? Would you mind providing a link to the documentation?

    Best regards,
    Ismael

    #1397422

    Hi,

    sorry, i’m not that good with JS. Here is the documentation: https://www.jqueryscript.net/animation/Snap-To-Section-SnapScroll.html

    I use a Codeblock for the call, maybe there is the error:
    <script>
    var snapScroll = $(“.av-layout-grid-container”).SnapScroll({
    hashes:true
    });
    console.log(snapScroll);
    </script>

    Could you help me please?

    And i was wondering why there isn’t a Scroll Snap function in the theme. There are a few posts about it in the forum.
    I also tried the CSS way with “scroll-snap-type” and “scroll-snap-align”, but it won’t work either, why?

    Best regards,
    Jasper

    #1397493

    Hi,
    Thanks for the link to your site, I see you are getting this error: Uncaught TypeError: $ is not a function this is because the code you added to the code block is this:

    <script>
        var snapScroll = $(".av-layout-grid-container").SnapScroll({
            hashes: true
        });
        console.log(snapScroll);
    </script>

    the problem is that your script needs to be wrapped like this:

    <script>
    (function($){
        var snapScroll = $(".av-layout-grid-container").SnapScroll({
            hashes: true
        });
        console.log(snapScroll);
    })(jQuery);
    </script>

    this should solve the error, if you are forcing jQuery into your footer try this:

    <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function($){
        var snapScroll = $(".av-layout-grid-container").SnapScroll({
            hashes: true
        });
        console.log(snapScroll);
    })(jQuery);
    });
    </script>

    If this doesn’t correct please include admin login in the Private Content area so we can investigate.

    Best regards,
    Mike

    #1397780

    Hi,
    thank you so much, it works fine in the footer.

    Now i have another problem. To work properly, the elements has to be full height of the browser (100vh).
    That works fine on desktop view but on mobile devices the content will cut off.
    Do you have any idea, how i can work around that problem?

    Thank you very much!
    Best regards,
    Jasper

    #1397805

    Hi,
    Glad to hear this helped, for mobile it looks like you are overriding the 100vh with 100%!important:

    @media only screen and (max-width: 480px){
    .av-layout-grid-container {
        height: 100% !important;
    }
    }

    I recommend using 100vh;
    and for the inner container you are adding: height: auto !important;

    media only screen and (max-width: 767px){
    .responsive #top #wrap_all .av-flex-cells .no_margin {
        display: block;
        margin: 0;
        height: auto !important;
        overflow: hidden;
        float: left;
        clear: none;
        width: 100%;
    }
    }

    I recommend setting the height to 50vh like this:

    @media only screen and (max-width: 767px) {
    .responsive #top #wrap_all #main .av-flex-cells .no_margin {
        height: 50vh !important;
    }
    }

    and changing the top padding for mobile to 20px from the current 70px, this looks like the text will then fully show, you could also tweak the font size a little or change the image height a little to allow more room for the text.

    Best regards,
    Mike

    #1397822

    Hi,
    thanks again for your quick help!

    With the changes and tweaking it almost works out but its a very limited user experience.
    Is there a way to leave the script out off mobile view?
    I’ve tested a few things but none of it worked?

    Thank you an best regards,
    Jasper

    #1397912

    Hi,
    Try changing your code block script to this to only allow it to run on screens above 767px:

    <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function($){
    	var width = $(window).width();
    	if (width >= 767) {
        var snapScroll = $(".av-layout-grid-container").SnapScroll({
            hashes: true
        });
        console.log(snapScroll);
        }
    })(jQuery);
    });
    </script>

    If you test with Dev Tools you must reload the page when emulating a mobile device, this will work correctly on actual devices.

    Best regards,
    Mike

    #1398263

    Thank you very much! :-)

    #1398267

    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 ‘Snap Scroll does not work’ is closed to new replies.