RuFFCuT
RuFFCuT

Reputation: 307

Creating a javascript popup box when user scrolls

A bit of a different question!

Does anyone know where there is either a plugin or point me in the right direction to create something like this: http://mashable.com/2012/05/30/kings-social-media/

When you get to the end of an article a box appears in the bottom right hand side of the screen!

Any ideas?

Thanks Ricky

Upvotes: 1

Views: 6200

Answers (2)

Steve Tauber
Steve Tauber

Reputation: 10159

jQuery inView plugin is super awesome. Just put a div at the bottom of your page and when it comes into view this handler will call your function.

http://remysharp.com/2009/01/26/element-in-view-event-plugin/

Upvotes: 0

Codeman
Codeman

Reputation: 12375

A simple example from a blog I found:

function getScrollY() 
{
    var y = 0;
    y = document.body.scrollBottom;
    return y
}

Then use this as a .js include (similar to this JSFiddle I found):

(function($) 
{
    $area.scroll(function(e) 
    {
        if($(this).scrollBottom() < $('#divToShowBoxOn').offset().left)
            alert("Zomg you scrolled to my box!");
    }
})(jQuery)​

where area is the place you want to measure from

Upvotes: 4

Related Questions