• Resolved jenniferchosson

    (@jenniferchosson)


    Hello,
    WHAT WORKS:
    I made a popup mapped with MailChimp. It works perfectly when I set the display option to “Scroll and/or time delay: 70% / 0sec”.

    WHAT I WANT

    I want the popup to display at the end of a post

    WHAT I TRIED
    I set this option to “Scroll to element: #respond”, or “.entry-footer”, but it never shows up.
    With firebug, I tried the jQuery selectors :
    $j = jQuery.noConflit();
    $j(“#respond”);
    $j(“.entry-footer”);

    Elements are well found.

    https://www.ads-software.com/plugins/dreamgrow-scroll-triggered-box/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jenniferchosson

    (@jenniferchosson)

    Looking at the JS, I think I found the problem.
    In the function ‘$DGD.placeBox = function (box)’, the plugin calculates the height of the wanted element, and converts it as a height rate, so it will act as a classical “scroll” setting. So the detector has to consider it as a scroll element. So I modified the condition to allow ‘element’ type:

    $DGD.calcScroll = function () {
    var scrolled = (document.body.scrollTop || parseInt(jQuery(document).scrollTop(), 10)),
    rate = Math.round((scrolled + 0.001) * 10 / (this.toScroll + 0.001)) * 10,
    i,
    box;
    for (i = 0; i < this.boxes_wait_for_scroll.length; i++) {
    box = this.boxes_wait_for_scroll[i];
    if ((box.trigger.action === ‘scroll’ || box.trigger.action === ‘element’) && rate >= box.trigger.scroll && box.hidden && !box.closed) {
    if (box.trigger.delaytime > 0) {
    this.regTimedOpening(box, box.trigger.delaytime);
    } else {
    this.showBox(box, false);
    }
    }
    if ((box.trigger.action === ‘scroll’ || box.trigger.action === ‘element’) && rate < box.trigger.scroll && !box.hidden) {
    this.hideBox(box);
    }
    }
    };

    Another solution could be to change the type of the box once we know the wanted scroll rate :

    if (box.trigger.action === ‘element’) {
    if (jQuery(box.trigger.element).length > 0) {
    elementheight = jQuery(box.trigger.element).offset().top;
    this.toScroll = this.docheight – this.screenheight;
    box.trigger.scroll = ((elementheight – this.screenheight) + 0.001) / (this.toScroll + 0.001) * 100;
    box.trigger.action = ‘scroll’;
    } else {
    box.trigger.scroll = 111;
    this.echo(‘Element ‘ + box.trigger.element + ‘ is missing’);
    }
    }

    Plugin Author Eero Hermlin

    (@eero-hermlin)

    Thanks for great find and solution! I will add the first solution to the code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Scroll to element doesn't work’ is closed to new replies.