You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Demo* (loading lolcats when they scroll into view): "http://tifftiff.de/jquery.inview/example/live_event.html":http://tifftiff.de/jquery.inview/example/live_event.html
@@ -15,19 +15,10 @@ The script makes use of the new $.contains method - so it will only work with jQ
15
15
The event will only fire when the element comes in to view of the viewport, and out of view. It won't keep firing if the user scrolls and the element remains in view.
16
16
17
17
The variable after the event argument indicates the visible state in the viewport.
18
-
The third variable visiblePartX detects which horizontal part of the element is visible to the user (possible values: left, right, both)
19
-
The fourth variable visiblePartY detects which vertical part of the element is visible to the user (possible values: top, bottom, both)
@@ -55,41 +46,9 @@ bc.. // Assuming that all images have set the 'data-src' attribute instead of t
55
46
$this.removeAttr("data-src");
56
47
});
57
48
58
-
h2. More complex example
59
-
60
-
This way we can attach inview to some DIV in our code to, for example, detect when it FULLY readed by user (user sees it's bottom and top) and only after 1 seconds of view, so after we call some out stats function or whatever
if (elem.data('seenTop') && elem.data('seenBottom')) {
82
-
elem.unbind('inview');
83
-
// here we will do WHAT WHE NEED (for ex. Call Ajax stats collector)
84
-
...
85
-
}
86
-
}, 1000));
87
-
}
88
-
});
89
-
90
49
h2. How it works
91
50
92
-
An interval in the background checks the position of the elements against the viewport dimensions and the scroll position.
51
+
An interval in the background checks the position of the bounding rectangle of elements against the viewport dimensions and the scroll position.
93
52
94
53
However, I wanted to create a utility that would only check the elements that were registered under the 'inview' event, i.e. I didn't want to keep checking the element list if we unbind from the event.
95
54
@@ -102,22 +61,7 @@ h2. Use cases
102
61
* Reduce http requests and traffic on server by loading assets (images, javascript, html, ...) only when they are visible to the user
103
62
* Endless scrolling (twitter-like)
104
63
* Tracking (eg. to see whether a user has read an entire article)
105
-
* ...
106
64
107
65
h2. Browser Compatibility
108
66
109
-
h4. The Test Suite succeeds in the following browsers that were tested:
110
-
111
-
* Firefox 3+
112
-
* Safari 3+
113
-
* Chrome 7+
114
-
* Opera 10+
115
-
* IE 6+
116
-
* Mobile Safari on iPad 4.2.2
117
-
* Fennec 4b on Android 2.2
118
-
* Opera Mobile 10.1b on Android 2.2
119
-
120
-
h4. The Test Suite doesn't completely succeed but the demos in this repository work without problems in the following browsers:
121
-
122
-
* Mobile WebKit on Android 2.2
123
-
* Mobile WebKit on Palm Pre 1
67
+
Haven't had a chance to test this yet, but the cornerstone of this plugin, getBoundingClientRect, should work in any modern browser as well as IE7+
0 commit comments