summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2017-09-20 10:53:17 -0500
committerClement Ho <ClemMakesApps@gmail.com>2017-09-20 10:53:17 -0500
commit2cd64406c4b71d96e7f7bc2fbb4551a9153f78cc (patch)
tree784736d543e62d62064a7ec409c197f2134e512f
parent727f51b8ef0af2b78087b4ac894ee728bfbabd1f (diff)
downloadgitlab-ce-2cd64406c4b71d96e7f7bc2fbb4551a9153f78cc.tar.gz
Force two up view
-rw-r--r--app/assets/javascripts/commit/image_file.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/assets/javascripts/commit/image_file.js b/app/assets/javascripts/commit/image_file.js
index 17d14dc1e79..aef8061c676 100644
--- a/app/assets/javascripts/commit/image_file.js
+++ b/app/assets/javascripts/commit/image_file.js
@@ -11,14 +11,22 @@
function ImageFile(file) {
this.file = file;
this.requestImageInfo($('.two-up.view .frame.deleted img', this.file), (function(_this) {
- // Determine if old and new file has same dimensions, if not show 'two-up' view
return function(deletedWidth, deletedHeight) {
return _this.requestImageInfo($('.two-up.view .frame.added img', _this.file), function(width, height) {
- if (width === deletedWidth && height === deletedHeight) {
- return _this.initViewModes();
- } else {
- return _this.initView('two-up');
- }
+ _this.initViewModes();
+
+ // Load two-up view after images are loaded
+ // so that we can display the correct width and height information
+ const images = $('.two-up.view img', _this.file);
+ let loadedCount = 0;
+
+ images.on('load', () => {
+ loadedCount += 1;
+
+ if (loadedCount === images.length) {
+ _this.initView('two-up');
+ }
+ });
});
};
})(this));