Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled initial event for off-view elements #50

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Element 'inview' Event Plugin

Event that is fired as soon as an element appears in the user's viewport.
Event that is fired when an element enters or leaves the user's viewport.

* **Author:** [Christopher Blum](http://twitter.com/ChristopherBlum)
* **Original idea and concept by:** [Remy Sharp](http://remysharp.com/2009/01/26/element-in-view-event-plugin/)
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protonet.jquery.inview",
"version": "1.1.2",
"name": "ch.crafft.jquery.inview",
"version": "1.1.3-crafft",
"main": "jquery.inview.js",
"description": "jQuery event that is fired as soon as an element appears in the user's viewport."
}
}
2 changes: 1 addition & 1 deletion jquery.inview.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
if (!inView) {
$element.data('inview', true).trigger('inview', [true]);
}
} else if (inView) {
} else if (inView || typeof inView === 'undefined') {
$element.data('inview', false).trigger('inview', [false]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion jquery.inview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ window['jQuery 1.8'].each(['jQuery 1.8', 'jQuery 1.12', 'jQuery 2.2'], function(

setTimeout(function() {
$(window).scrollTop(0).scrollLeft(0);
ok(!firstCall, 'inview shouldn\'t be triggered initially when the element isn\'t in the viewport');
ok(firstCall, 'Triggered handler initially even when the element isn\'t in the viewport');
element.unbind('inview.firstCall');
element.bind('inview.secondCall', function(event, inViewParam) {
secondCall = true;
Expand Down Expand Up @@ -99,7 +99,7 @@ window['jQuery 1.8'].each(['jQuery 1.8', 'jQuery 1.12', 'jQuery 2.2'], function(
setTimeout(function() {
$(window).scrollTop(0).scrollLeft(0);

ok(!firstCall, 'inview shouldn\'t be triggered initially when the element isn\'t in the viewport');
ok(firstCall, 'Triggered handler initially even when the element isn\'t in the viewport');
element.unbind('inview.firstCall');
element.bind('inview.secondCall', function(event, inViewParam) {
secondCall = true;
Expand Down