Clear event listener

This commit is contained in:
Zixaphir 2014-04-07 10:49:11 -07:00
parent d2727c4054
commit 82314241b7
3 changed files with 13 additions and 7 deletions

View File

@ -8403,7 +8403,7 @@
return ImageLoader.thread = this; return ImageLoader.thread = this;
}, },
node: function() { node: function() {
var URL, file, isImage, isVideo, match, replace, style, thumb, type, _ref, _ref1; var URL, cb, file, isImage, isVideo, match, replace, style, thumb, type, _ref, _ref1;
if (!this.file) { if (!this.file) {
return; return;
} }
@ -8436,8 +8436,9 @@
$.on(file, 'mouseover', ImageHover.mouseover); $.on(file, 'mouseover', ImageHover.mouseover);
} }
} }
$.on(file, 'load loadedmetadata', (function(_this) { cb = (function(_this) {
return function() { return function() {
$.off(file, 'load loadedmetadata', cb);
if (isVideo) { if (isVideo) {
$.replace(thumb, file); $.replace(thumb, file);
_this.file.thumb = file; _this.file.thumb = file;
@ -8445,7 +8446,8 @@
} }
return thumb.src = URL; return thumb.src = URL;
}; };
})(this)); })(this);
$.on(file, 'load loadedmetadata', cb);
} }
return file.src = URL; return file.src = URL;
}, },

View File

@ -8420,7 +8420,7 @@
return ImageLoader.thread = this; return ImageLoader.thread = this;
}, },
node: function() { node: function() {
var URL, file, isImage, isVideo, match, replace, style, thumb, type, _ref, _ref1; var URL, cb, file, isImage, isVideo, match, replace, style, thumb, type, _ref, _ref1;
if (!this.file) { if (!this.file) {
return; return;
} }
@ -8453,8 +8453,9 @@
$.on(file, 'mouseover', ImageHover.mouseover); $.on(file, 'mouseover', ImageHover.mouseover);
} }
} }
$.on(file, 'load loadedmetadata', (function(_this) { cb = (function(_this) {
return function() { return function() {
$.off(file, 'load loadedmetadata', cb);
if (isVideo) { if (isVideo) {
$.replace(thumb, file); $.replace(thumb, file);
_this.file.thumb = file; _this.file.thumb = file;
@ -8462,7 +8463,8 @@
} }
return thumb.src = URL; return thumb.src = URL;
}; };
})(this)); })(this);
$.on(file, 'load loadedmetadata', cb);
} }
return file.src = URL; return file.src = URL;
}, },

View File

@ -50,13 +50,15 @@ ImageLoader =
file.autoplay = Conf['Autoplay'] file.autoplay = Conf['Autoplay']
if Conf['Image Hover'] if Conf['Image Hover']
$.on file, 'mouseover', ImageHover.mouseover $.on file, 'mouseover', ImageHover.mouseover
$.on file, 'load loadedmetadata', => cb = =>
$.off file, 'load loadedmetadata', cb
# Replace the thumbnail once the file has finished loading. # Replace the thumbnail once the file has finished loading.
if isVideo if isVideo
$.replace thumb, file $.replace thumb, file
@file.thumb = file # XXX expanding requires the post.file.thumb node. @file.thumb = file # XXX expanding requires the post.file.thumb node.
return return
thumb.src = URL thumb.src = URL
$.on file, 'load loadedmetadata', cb
file.src = URL file.src = URL
toggle: -> toggle: ->