OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
6 * @fileoverview First run UI. | 6 * @fileoverview First run UI. |
7 */ | 7 */ |
8 | 8 |
9 // <include src="step.js"> | 9 // <include src="step.js"> |
10 | 10 |
11 // Transitions durations. | 11 // Transitions durations. |
12 /** @const */ var DEFAULT_TRANSITION_DURATION_MS = 400; | 12 /** @const */ var DEFAULT_TRANSITION_DURATION_MS = 400; |
13 /** @const */ var BG_TRANSITION_DURATION_MS = 800; | 13 /** @const */ var BG_TRANSITION_DURATION_MS = 800; |
14 | 14 |
15 /** | 15 /** |
16 * Changes visibility of element with animated transition. | 16 * Changes visibility of element with animated transition. |
17 * @param {Element} element Element which visibility should be changed. | 17 * @param {Element} element Element which visibility should be changed. |
18 * @param {boolean} visible Whether element should be visible after transition. | 18 * @param {boolean} visible Whether element should be visible after transition. |
19 * @param {number=} opt_transitionDuration Time length of transition in | 19 * @param {number=} opt_transitionDuration Time length of transition in |
20 * milliseconds. Default value is DEFAULT_TRANSITION_DURATION_MS. | 20 * milliseconds. Default value is DEFAULT_TRANSITION_DURATION_MS. |
21 * @param {function()=} opt_onFinished Called after transition has finished. | 21 * @param {function()=} opt_onFinished Called after transition has finished. |
22 */ | 22 */ |
23 function changeVisibility( | 23 function changeVisibility( |
24 element, visible, opt_transitionDuration, opt_onFinished) { | 24 element, visible, opt_transitionDuration, opt_onFinished) { |
Dan Beam
2017/02/13 06:24:39
i'm fairly sure that something in this method is b
| |
25 var classes = element.classList; | 25 var classes = element.classList; |
26 // If target visibility is the same as current element visibility. | 26 // If target visibility is the same as current element visibility. |
27 if (classes.contains('transparent') === !visible) { | 27 if (classes.contains('transparent') === !visible) { |
28 if (opt_onFinished) | 28 if (opt_onFinished) |
29 opt_onFinished(); | 29 opt_onFinished(); |
30 return; | 30 return; |
31 } | 31 } |
32 var transitionDuration = (opt_transitionDuration === undefined) ? | 32 var transitionDuration = (opt_transitionDuration === undefined) ? |
33 cr.FirstRun.getDefaultTransitionDuration() : opt_transitionDuration; | 33 cr.FirstRun.getDefaultTransitionDuration() : opt_transitionDuration; |
34 var style = element.style; | 34 var style = element.style; |
35 var oldDurationValue = style.getPropertyValue('transition-duration'); | 35 var oldDurationValue = style.getPropertyValue('transition-duration'); |
36 style.setProperty('transition-duration', transitionDuration + 'ms'); | 36 style.setProperty('transition-duration', transitionDuration + 'ms'); |
37 var transition = visible ? 'show-animated' : 'hide-animated'; | 37 var transition = visible ? 'show-animated' : 'hide-animated'; |
38 classes.add(transition); | 38 classes.add(transition); |
39 classes.toggle('transparent'); | 39 classes.toggle('transparent'); |
40 element.addEventListener('webkitTransitionEnd', function f() { | 40 element.addEventListener('transitionend', function f() { |
41 element.removeEventListener('webkitTransitionEnd', f); | 41 element.removeEventListener('transitionend', f); |
42 classes.remove(transition); | 42 classes.remove(transition); |
43 if (oldDurationValue) | 43 if (oldDurationValue) |
44 style.setProperty('transition-duration', oldDurationValue); | 44 style.setProperty('transition-duration', oldDurationValue); |
45 else | 45 else |
46 style.removeProperty('transition-duration'); | 46 style.removeProperty('transition-duration'); |
47 if (opt_onFinished) | 47 if (opt_onFinished) |
48 opt_onFinished(); | 48 opt_onFinished(); |
49 }); | 49 }); |
50 ensureTransitionEndEvent(element, transitionDuration); | 50 ensureTransitionEndEvent(element, transitionDuration); |
51 } | 51 } |
(...skipping 218 matching lines...) Loading... | |
270 } | 270 } |
271 }; | 271 }; |
272 }); | 272 }); |
273 | 273 |
274 /** | 274 /** |
275 * Initializes UI. | 275 * Initializes UI. |
276 */ | 276 */ |
277 window.onload = function() { | 277 window.onload = function() { |
278 cr.FirstRun.initialize(); | 278 cr.FirstRun.initialize(); |
279 }; | 279 }; |
OLD | NEW |