OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * The ExtensionOptionsOverlay will show an extension's options page using | 9 * The ExtensionOptionsOverlay will show an extension's options page using |
10 * an <extensionoptions> element. | 10 * an <extensionoptions> element. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 extensionoptions.onpreferredsizechanged = function(evt) { | 114 extensionoptions.onpreferredsizechanged = function(evt) { |
115 var oldWidth = parseInt(overlayStyle.width, 10); | 115 var oldWidth = parseInt(overlayStyle.width, 10); |
116 var oldHeight = parseInt(overlayStyle.height, 10); | 116 var oldHeight = parseInt(overlayStyle.height, 10); |
117 var newWidth = Math.max(evt.width, minWidth); | 117 var newWidth = Math.max(evt.width, minWidth); |
118 var newHeight = Math.min(evt.height, maxHeight); | 118 var newHeight = Math.min(evt.height, maxHeight); |
119 | 119 |
120 // animationTime is the amount of time in ms that will be used to resize | 120 // animationTime is the amount of time in ms that will be used to resize |
121 // the overlay. It is calculated by multiplying the pythagorean distance | 121 // the overlay. It is calculated by multiplying the pythagorean distance |
122 // between old and the new size (in px) with a constant speed of | 122 // between old and the new size (in px) with a constant speed of |
123 // 0.25 ms/px. | 123 // 0.25 ms/px. |
124 var animationTime = 0.25 * Math.sqrt( | 124 var loading = document.documentElement.classlist.contains('loading'); |
Dan Beam
2015/02/04 19:09:30
note: this doesn't work all that well but will whe
| |
125 Math.pow(newWidth - oldWidth, 2) + | 125 var animationTime = loading ? 0 : |
126 Math.pow(newHeight - oldHeight, 2)); | 126 0.25 * Math.sqrt(Math.pow(newWidth - oldWidth, 2) + |
127 Math.pow(newHeight - oldHeight, 2)); | |
127 | 128 |
128 if (animation) { | 129 if (animation) { |
129 animation.cancel(); | 130 animation.cancel(); |
130 } | 131 } |
131 animation = overlay.animate([ | 132 animation = overlay.animate([ |
132 {width: oldWidth + 'px', height: oldHeight + 'px'}, | 133 {width: oldWidth + 'px', height: oldHeight + 'px'}, |
133 {width: newWidth + 'px', height: newHeight + 'px'} | 134 {width: newWidth + 'px', height: newHeight + 'px'} |
134 ], { | 135 ], { |
135 duration: animationTime, | 136 duration: animationTime, |
136 delay: 0 | 137 delay: 0 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 /** @type {HTMLDivElement} */($('extension-options-overlay')) : | 174 /** @type {HTMLDivElement} */($('extension-options-overlay')) : |
174 null); | 175 null); |
175 } | 176 } |
176 }; | 177 }; |
177 | 178 |
178 // Export | 179 // Export |
179 return { | 180 return { |
180 ExtensionOptionsOverlay: ExtensionOptionsOverlay | 181 ExtensionOptionsOverlay: ExtensionOptionsOverlay |
181 }; | 182 }; |
182 }); | 183 }); |
OLD | NEW |