diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-09-21 17:33:19 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-09-21 17:33:19 +0000 |
commit | 3ce3614089b16f670ac91524302280c906dd4815 (patch) | |
tree | 61d473ab00e16b1683b8cc5b8b1a15e8e301319e | |
parent | b3544dfe115ae596505fd1c6c09981cf33c96ece (diff) | |
parent | 71bc619eba4f205261b29b9f2d6208e48033206c (diff) | |
download | gitlab-ce-3ce3614089b16f670ac91524302280c906dd4815.tar.gz |
Merge branch 'force-two-up-view' into 'master'
Force two up view
Closes #32613
See merge request gitlab-org/gitlab-ce!14397
-rw-r--r-- | app/assets/javascripts/commit/image_file.js | 20 | ||||
-rw-r--r-- | changelogs/unreleased/force-two-up-view.yml | 5 |
2 files changed, 19 insertions, 6 deletions
diff --git a/app/assets/javascripts/commit/image_file.js b/app/assets/javascripts/commit/image_file.js index bb33e9eb783..4763985c802 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)); diff --git a/changelogs/unreleased/force-two-up-view.yml b/changelogs/unreleased/force-two-up-view.yml new file mode 100644 index 00000000000..1074eb384bb --- /dev/null +++ b/changelogs/unreleased/force-two-up-view.yml @@ -0,0 +1,5 @@ +--- +title: Force two up view to load by default for image diffs +merge_request: +author: +type: fixed |