Viewing 15 replies - 1 through 15 (of 24 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    In the second link it looks like the content is constantly loading as you scroll, preventing you from scrolling down. Is that the issue?

    Thread Starter achohanc6

    (@achohanc6)

    Yes that is part of the issue, the more concering issue is when a user tries to scroll either up/down once they stop scrolling to view the site at any point (usually futher down on both pages) the page starts to scroll up on its own.

    How do I fix this?

    Thread Starter achohanc6

    (@achohanc6)

    When I inspected the page and click on ‘Console” in Chrome it show this error:

    Attempted to auto-scroll to element with data-scroll-name [], but could not find any elements with that name.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Does the page start scrolling up while the scrollbar is getting smaller?

    Thread Starter achohanc6

    (@achohanc6)

    No the size of the scrollbar does not change. Are you able to view the two links I sent you to see the issue?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I checked the first link but couldn’t replicate it, but now that I check again I see the issue.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you try deactivating your plugins to explore whether any could be responsible? If none are it’s likely to be related to your theme, so I would recommend contacting your theme authors about this: https://candyboxmarketing.com

    Thread Starter achohanc6

    (@achohanc6)

    The problem is I can cannot contact the theme authors that isn’t a possibility. I will test the plugins out to see if that is the issue. Isn’t there a way to change this through the code? I think this piece of code is what is triggering the scrolling:

    Smooth Scrolling JS

    Automatically detects changes to the pages hash and scrolls the user to the corresponding element. Checks on load if there is a hash, and attempts to find it.

    Element should be set up with the following attributes:
    <div data-scroll-name=’UNIQUENAME’
    data-scroll-speed=’Jquery Speed’ optional, defaults to ‘slow’
    data-scroll=offset=’-200′ offset in px you’d like the scroll to stop at. Good for accomodating header bars. Defaults to -50.
    >

    Call the watcher to queue up the doer

    */
    //Watcher
    function watchForSmoothScrolls(){
    jQuery(window).bind(‘hashchange’, function(){
    var newHash = location.hash.substring(1);
    scrollTo(newHash);
    });
    var newHash = location.hash.substring(1);
    scrollTo(newHash);
    }

    //Doer
    function scrollTo(anchor){
    var $elem = jQuery(“[data-scroll-name='”+ anchor +”‘]”);
    if($elem.length == 0){
    console.warn(‘Attempted to auto-scroll to element with data-scroll-name [‘ + anchor + ‘], but could not find any elements with that name.’);
    return false;
    }
    var scroll_speed = $elem.attr(‘data-scroll-speed’);
    if(!scroll_speed){
    scroll_speed = ‘slow’;
    }
    var scroll_offset = parseInt($elem.attr(‘data-scroll-offset’));
    if(!scroll_offset){
    scroll_offset = -100;
    }

    jQuery(‘html,body’).animate({scrollTop: ($elem.offset().top + scroll_offset)},scroll_speed);
    }

    /*

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Do you know which file that script contains it? I tried looking but it seems you have an optimisation plugin installed that is collating everything into an unreadable (to humans) format.

    Thread Starter achohanc6

    (@achohanc6)

    The name of the file is cbm-utils.js

    Thread Starter achohanc6

    (@achohanc6)

    This is what is in this file:

    /*
    Reference: How to use jQuery’s $ function anywhere:

    (function( $ ) {

    })(jQuery);
    */

    //Came with Joints WP, several fixes
    function joints_wp_fixes(){
    (function( $ ) {
    // Remove empty P tags created by WP inside of Accordion and Orbit
    $(‘.accordion p:empty, .orbit p:empty’).remove();

    // Makes sure last grid item floats left
    $(‘.archive-grid .columns’).last().addClass( ‘end’ );

    // Adds Flex Video to YouTube and Vimeo Embeds
    $(‘iframe[src*=”youtube.com”], iframe[src*=”vimeo.com”]’).each(function() {
    if ( $(this).innerWidth() / $(this).innerHeight() > 1.5 ) {
    $(this).wrap(“<div class=’widescreen flex-video’/>”);
    } else {
    $(this).wrap(“<div class=’flex-video’/>”);
    }
    });
    })(jQuery);
    }

    /*

    Smooth Scrolling JS

    Automatically detects changes to the pages hash and scrolls the user to the corresponding element. Checks on load if there is a hash, and attempts to find it.

    Element should be set up with the following attributes:
    <div data-scroll-name=’UNIQUENAME’
    data-scroll-speed=’Jquery Speed’ optional, defaults to ‘slow’
    data-scroll=offset=’-200′ offset in px you’d like the scroll to stop at. Good for accomodating header bars. Defaults to -50.
    >

    Call the watcher to queue up the doer

    */
    //Watcher
    function watchForSmoothScrolls(){
    jQuery(window).bind(‘hashchange’, function(){
    var newHash = location.hash.substring(1);
    scrollTo(newHash);
    });
    var newHash = location.hash.substring(1);
    scrollTo(newHash);
    }

    //Doer
    function scrollTo(anchor){
    var $elem = jQuery(“[data-scroll-name='”+ anchor +”‘]”);
    if($elem.length == 0){
    console.warn(‘Attempted to auto-scroll to element with data-scroll-name [‘ + anchor + ‘], but could not find any elements with that name.’);
    return false;
    }
    var scroll_speed = $elem.attr(‘data-scroll-speed’);
    if(!scroll_speed){
    scroll_speed = ‘slow’;
    }
    var scroll_offset = parseInt($elem.attr(‘data-scroll-offset’));
    if(!scroll_offset){
    scroll_offset = -100;
    }

    jQuery(‘html,body’).animate({scrollTop: ($elem.offset().top + scroll_offset)},scroll_speed);
    }

    /*

    Full size hero videos

    HTML (put directly in banner-block, parent is full size. Have overflow hidden.)
    <div id=’hero-vid-holder’>
    <iframe src=”https://player.vimeo.com/video/&lt;?= $hero_vid ?>?background=1&loop=1″ width=”100%” height=”100%” frameborder=”0″ webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    </div>

    CSS
    #hero-vid-holder {
    width: 100%;
    height: 775px;
    iframe {
    width: 100%;
    height: 100%;
    }
    }
    */

    //Watcher
    function watchForHeroVideos(){
    jQuery(window).on(‘resize’, heroVideoSizer).resize();
    }

    //Doer
    function heroVideoSizer(){
    $container = jQuery(‘#hero-vid-holder’);
    aspect_ratio = 9 / 16;
    min_height = $container.parent().height();
    window_width = jQuery(window).width();
    container_height = aspect_ratio * window_width;

    if(container_height < min_height){
    //Center the vid
    margin_left = -1 * ((min_height – container_height) / 2);

    //Set the width
    container_width = min_height / aspect_ratio;
    container_height = ‘100%’;

    } else {
    //Set the height
    container_width = ‘100%’;
    margin_left = ‘0px’;
    }

    $container
    .css(‘height’, container_height)
    .css(‘width’, container_width)
    .css(‘margin-left’, margin_left);
    }

    /*

    For when you have to validate an email. Works with black magic

    */
    function validateEmail(email) {
    var re = /^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
    }

    /*

    Video modals

    Simple use:
    <div data-video-url='<?= $url ?>’>Video!</div>

    With an image + mask
    <div class=”video-with-overlay” data-video-url='<?= $url ?>’>
    ” />
    <div>
    /assets/images/homepage-video-mask.png” />
    <i class=”fa fa-play-circle-o” aria-hidden=”true”></i>
    </div>
    </div>
    */

    function registerVideoModals(){
    jQuery(“[data-video-url]”).each(function(){
    $this = jQuery(this);
    video_url = $this.attr(“data-video-url”);

    if (/vimeo/i.test(video_url)) {
    //IN
    // https://vimeo.com/16536655
    //OUT
    // https://player.vimeo.com/video/16536655
    video_id = /[^/]*$/.exec(video_url)[0];
    video_iframe_src = “https://player.vimeo.com/video/&#8221; + video_id;
    this_id = “video-modal-” + guid();
    iframe = jQuery(“<iframe src='” + video_iframe_src + “‘ frameborder=’0′ webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>”);
    close_button = jQuery(“<button class=’close-button’ data-close aria-label=’Close video’ type=’button’>”)
    .append(jQuery(‘<i class=”fa fa-times-circle-o” aria-hidden=”true”></i>’));
    modal = jQuery(“<div class=’reveal video-modal’ id='” + this_id + “‘ data-reveal data-reset-on-close=’true’>”)
    .append(close_button)
    .append(iframe);

    jQuery(“body”).append(modal);

    $this.attr(“data-open”, this_id);

    var elem = new Foundation.Reveal(modal);
    }

    });
    }

    function guid() {
    function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
    .toString(16)
    .substring(1);
    }
    return s4() + s4() + ‘-‘ + s4() + ‘-‘ + s4() + ‘-‘ +
    s4() + ‘-‘ + s4() + s4() + s4();
    }

    function bindFileUploads(){
    jQuery(‘.gf_file_upload input’).bind(‘change’, function(){
    fpath = jQuery(this).val();
    filename = fpath.split(“\\”).pop();
    jQuery(‘.gf_file_upload label’).attr(‘data-filename’, filename).attr(‘data-status’, ‘DONE’);

    });
    }

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    tip; try adding ?ao_noptimize=1 to the URL @anevins, that should disable autoptimize for that request ??

    Thread Starter achohanc6

    (@achohanc6)

    Can I email you the file?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Thanks @optimizingmatters, unfortunately I need the OP to deactivate the optimisation plugin to use Chrome’s breakpoint tools and read what’s going on.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘scrolling in Chrome’ is closed to new replies.