Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: chrome/browser/resources/extensions/extension_options_overlay.js

Issue 480243003: Implement smoother autosizing of the extension options overlay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move <extensionoptions> off screen until overlay is ready Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/extensions/extension_options_overlay.js
diff --git a/chrome/browser/resources/extensions/extension_options_overlay.js b/chrome/browser/resources/extensions/extension_options_overlay.js
index 899098d625ec446767be32d832602b97367fd582..5e062f53b2d88ff0c748a4e705f6def6ad386a71 100644
--- a/chrome/browser/resources/extensions/extension_options_overlay.js
+++ b/chrome/browser/resources/extensions/extension_options_overlay.js
@@ -49,7 +49,7 @@ cr.define('extensions', function() {
this.setVisible_(false);
var extensionoptions = document.querySelector('extensionoptions');
if (extensionoptions)
- $('extension-options-overlay').removeChild(extensionoptions);
+ $('extension-options-overlay-guest').removeChild(extensionoptions);
},
/**
@@ -64,14 +64,54 @@ cr.define('extensions', function() {
extensionoptions.extension = extensionId;
extensionoptions.autosize = 'on';
- // TODO(ericzeng): Resize in a non-jarring way.
+ var headerStyle =
not at google - send to devlin 2014/08/20 02:07:15 You might want to add a meta-comment here, like:
ericzeng 2014/08/20 18:44:07 Done.
+ window.getComputedStyle($('extension-options-overlay-title'));
+ var headerHeight = parseInt(headerStyle.lineHeight) +
+ parseInt(headerStyle.paddingTop) +
+ parseInt(headerStyle.paddingBottom);
not at google - send to devlin 2014/08/20 02:07:15 Can you get this from one of the other height prop
+ var overlayMaxHeight =
+ parseInt($('extension-options-overlay').style.maxHeight);
+ extensionoptions.maxheight = overlayMaxHeight - headerHeight;
+
+ extensionoptions.minwidth =
+ parseInt(window.getComputedStyle($('extension-options-overlay'))
+ .minWidth);
+
+ extensionoptions.shouldDeferAutoSize(true);
not at google - send to devlin 2014/08/20 02:07:15 You mention in the comment that you don't actually
ericzeng 2014/08/20 02:23:30 Oh, I tried removing it and it turns out that it l
+
extensionoptions.onsizechanged = function(evt) {
- $('extension-options-overlay').style.width = evt.width;
- $('extension-options-overlay').style.height = evt.height;
+ var overlayStyle =
+ window.getComputedStyle($('extension-options-overlay'));
+ var oldWidth = parseInt(overlayStyle.width);
+ var oldHeight = parseInt(overlayStyle.height);
+
+ // animationTime is the amount of time in ms that will be used to resize
+ // the overlay. It is a function of the pythagorean distance between old
+ // and the new size, so that the speed at which the overlay changes is
+ // constant for all sizes.
not at google - send to devlin 2014/08/20 02:07:15 Nit: could you say like "0.25 means the popup resi
ericzeng 2014/08/20 18:44:07 Done.
+ var animationTime = 0.25 * Math.sqrt(
+ Math.pow(evt.newWidth - oldWidth, 2) +
+ Math.pow(evt.newHeight - oldHeight, 2));
+
+ var player = $('extension-options-overlay').animate([
+ {width: oldWidth + 'px', height: oldHeight + 'px'},
+ {width: evt.newWidth + 'px', height: evt.newHeight + 'px'}
+ ], {
+ duration: animationTime,
+ delay: 0
+ });
+
+ player.onfinish = function(e) {
+ extensionoptions.resumeDeferredAutoSize();
not at google - send to devlin 2014/08/20 02:07:15 Heh how did you figure out how to use animate... d
ericzeng 2014/08/20 02:23:30 This was sufficient documentation for me to implem
not at google - send to devlin 2014/08/20 02:29:34 Specifically I was wondering about an onerror or o
ericzeng 2014/08/20 18:44:07 Hm, I can't actually open that link, do you have t
+ $('extension-options-overlay-guest').style.position = 'static';
+ $('extension-options-overlay-guest').style.left = 'auto';
+ };
}.bind(this);
- $('extension-options-overlay').appendChild(extensionoptions);
+ $('extension-options-overlay-guest').style.position = 'absolute';
+ $('extension-options-overlay-guest').style.left = '10000px';
not at google - send to devlin 2014/08/20 02:07:15 This is to implement that off-screen resize? You
ericzeng 2014/08/20 18:44:07 Done.
+ $('extension-options-overlay-guest').appendChild(extensionoptions);
$('extension-options-overlay-title').textContent = extensionName;
this.setVisible_(true);

Powered by Google App Engine
This is Rietveld 408576698