S
S
Sergei Nalomenko2011-11-24 12:11:08
JavaScript
Sergei Nalomenko, 2011-11-24 12:11:08

jQuery: "Element viewed" event?

Hello habra community!

There was a need to somehow handle the event of the full appearance of the object (in this case, div, although this, in fact, does not matter) in the scope of the browser window. To be more precise, you need to send an ajax request to the server, which assigns the “read” status to the comment as soon as the user conditionally “read” it (the comment came into his field of vision).

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nes, 2011-11-24
@nes

You can implement this with jQuery.offset() and jQuery.scrollTop(). Well, throw it out, for example, trigger("shown")

F
Finom, 2011-11-24
@Finom

Maybe this plugin will help you: imakewebthings.github.com/jquery-waypoints/

K
Konstantin Kitmanov, 2011-11-24
@k12th

Track the change in window.scrollTop
Find the coordinates of the desired div - x1, y1, x2, y2
Check if the rectangle falls completely into the rectangle window.scrollTop, window.scrollLeft, get the viewport correct with the doctype in mind).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question