Skip to content

Commit

Permalink
Fix event target for Firefox.
Browse files Browse the repository at this point in the history
This commit fixes a crucial bug in Firefox that was preventing the
proper loading of images.
  • Loading branch information
squat committed Oct 23, 2013
1 parent 015bb42 commit ee6cbc9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "postpone",
"main": "index.js",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/lsvx/postpone",
"authors": [
"Lucas Serven <lserven@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "postpone",
"repo": "lsvx/postpone",
"description": "A polyfill for postponing the loading of media.",
"version": "0.3.0",
"version": "0.3.1",
"keywords": ["postpone", "media", "resource", "priority", "download"],
"dependencies": {},
"development": {},
Expand Down
4 changes: 2 additions & 2 deletions docs/Postpone.html
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line384">line 384</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line386">line 386</a>
</li></ul></dd>


Expand Down Expand Up @@ -2372,7 +2372,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Postpone
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Sun Oct 13 2013 02:31:32 GMT-0400 (EDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Wed Oct 23 2013 19:50:06 GMT-0400 (EDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Postpone
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Sun Oct 13 2013 02:31:32 GMT-0400 (EDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Wed Oct 23 2013 19:50:06 GMT-0400 (EDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Postpone
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Sun Oct 13 2013 02:31:32 GMT-0400 (EDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Wed Oct 23 2013 19:50:06 GMT-0400 (EDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
10 changes: 6 additions & 4 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ <h1 class="page-title">Source: index.js</h1>
* @returns this
*/
Postpone.prototype.scrollHandler = function( e ) {
var scrollElement = e.srcElement,
var scrollElement = e.srcElement || e.target,
elements = this.scrollElements[ scrollElement === window.document ? scrollElement = "window" : scrollElement.getAttribute( "data-id" ) ],
element = {},
scrolledIntoView = false;
Expand Down Expand Up @@ -337,7 +337,7 @@ <h1 class="page-title">Source: index.js</h1>
var temp = el,
o = 0;
/** Iterate over all parents of el up to body to find the vertical offset. */
while ( temp && temp.tagName.toLowerCase() !== "body" ) {
while ( temp && temp.tagName.toLowerCase() !== "body" && temp.tagName.toLowerCase() !== "html" ) {
o += temp.offsetTop;
temp = temp.offsetParent;
}
Expand Down Expand Up @@ -378,7 +378,9 @@ <h1 class="page-title">Source: index.js</h1>
/** If no scroll element is specified, then assume the scroll element is the window. */
scrollElement = scrollElement? scrollElement : "window";

if ( scrollElement === "window" ) scrollElement = document.body;
if ( scrollElement === "window" ) {
scrollElement = document.documentElement.scrollTop ? document.documentElement : document.body;
}
/** Use clientHeight instead of window.innerHeight for compatability with ie8. */
var viewPortHeight = document.documentElement.clientHeight,
top = this.offsetTop( el ),
Expand Down Expand Up @@ -464,7 +466,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Postpone
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Sun Oct 13 2013 02:31:32 GMT-0400 (EDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.1</a> on Wed Oct 23 2013 19:50:06 GMT-0400 (EDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Postpone.prototype.stop = function() {
* @returns this
*/
Postpone.prototype.scrollHandler = function( e ) {
var scrollElement = e.srcElement,
var scrollElement = e.srcElement || e.target,
elements = this.scrollElements[ scrollElement === window.document ? scrollElement = "window" : scrollElement.getAttribute( "data-id" ) ],
element = {},
scrolledIntoView = false;
Expand Down Expand Up @@ -310,7 +310,7 @@ Postpone.prototype.offsetTop = function( el ) {
var temp = el,
o = 0;
/** Iterate over all parents of el up to body to find the vertical offset. */
while ( temp && temp.tagName.toLowerCase() !== "body" ) {
while ( temp && temp.tagName.toLowerCase() !== "body" && temp.tagName.toLowerCase() !== "html" ) {
o += temp.offsetTop;
temp = temp.offsetParent;
}
Expand Down Expand Up @@ -351,7 +351,9 @@ Postpone.prototype.isInViewport = function( el, scrollElement ) {
/** If no scroll element is specified, then assume the scroll element is the window. */
scrollElement = scrollElement? scrollElement : "window";

if ( scrollElement === "window" ) scrollElement = document.body;
if ( scrollElement === "window" ) {
scrollElement = document.documentElement.scrollTop ? document.documentElement : document.body;
}
/** Use clientHeight instead of window.innerHeight for compatability with ie8. */
var viewPortHeight = document.documentElement.clientHeight,
top = this.offsetTop( el ),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postpone",
"version": "0.3.0",
"version": "0.3.1",
"description": "A polyfill for postponing the loading of media.",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit ee6cbc9

Please sign in to comment.