From 82314241b73029d2eab475513d6aa0cb70d5b55d Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 7 Apr 2014 10:49:11 -0700 Subject: [PATCH] Clear event listener --- builds/4chan-X.user.js | 8 +++++--- builds/crx/script.js | 8 +++++--- src/Images/ImageLoader.coffee | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a7adbf4d9..0b50c7894 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -8403,7 +8403,7 @@ return ImageLoader.thread = this; }, 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) { return; } @@ -8436,8 +8436,9 @@ $.on(file, 'mouseover', ImageHover.mouseover); } } - $.on(file, 'load loadedmetadata', (function(_this) { + cb = (function(_this) { return function() { + $.off(file, 'load loadedmetadata', cb); if (isVideo) { $.replace(thumb, file); _this.file.thumb = file; @@ -8445,7 +8446,8 @@ } return thumb.src = URL; }; - })(this)); + })(this); + $.on(file, 'load loadedmetadata', cb); } return file.src = URL; }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 79aee4f6c..cbf50f93e 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -8420,7 +8420,7 @@ return ImageLoader.thread = this; }, 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) { return; } @@ -8453,8 +8453,9 @@ $.on(file, 'mouseover', ImageHover.mouseover); } } - $.on(file, 'load loadedmetadata', (function(_this) { + cb = (function(_this) { return function() { + $.off(file, 'load loadedmetadata', cb); if (isVideo) { $.replace(thumb, file); _this.file.thumb = file; @@ -8462,7 +8463,8 @@ } return thumb.src = URL; }; - })(this)); + })(this); + $.on(file, 'load loadedmetadata', cb); } return file.src = URL; }, diff --git a/src/Images/ImageLoader.coffee b/src/Images/ImageLoader.coffee index 09b4c0258..e9b638b20 100755 --- a/src/Images/ImageLoader.coffee +++ b/src/Images/ImageLoader.coffee @@ -50,13 +50,15 @@ ImageLoader = file.autoplay = Conf['Autoplay'] if Conf['Image Hover'] $.on file, 'mouseover', ImageHover.mouseover - $.on file, 'load loadedmetadata', => + cb = => + $.off file, 'load loadedmetadata', cb # Replace the thumbnail once the file has finished loading. if isVideo $.replace thumb, file @file.thumb = file # XXX expanding requires the post.file.thumb node. return thumb.src = URL + $.on file, 'load loadedmetadata', cb file.src = URL toggle: ->