Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * | 10 * |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.Sideba rSizeChanged, this.sidebarSize()); | 501 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.Sideba rSizeChanged, this.sidebarSize()); |
| 502 } | 502 } |
| 503 }, | 503 }, |
| 504 | 504 |
| 505 /** | 505 /** |
| 506 * @param {boolean} reverse | 506 * @param {boolean} reverse |
| 507 * @param {function()=} callback | 507 * @param {function()=} callback |
| 508 */ | 508 */ |
| 509 _animate: function(reverse, callback) | 509 _animate: function(reverse, callback) |
| 510 { | 510 { |
| 511 var animationTime = 50; | |
| 512 this._animationCallback = callback; | 511 this._animationCallback = callback; |
| 513 | 512 |
| 514 var animatedMarginPropertyName; | 513 var animatedMarginPropertyName; |
| 515 if (this._isVertical) | 514 if (this._isVertical) |
| 516 animatedMarginPropertyName = this._secondIsSidebar ? "margin-right" : "margin-left"; | 515 animatedMarginPropertyName = this._secondIsSidebar ? "margin-right" : "margin-left"; |
| 517 else | 516 else |
| 518 animatedMarginPropertyName = this._secondIsSidebar ? "margin-bottom" : "margin-top"; | 517 animatedMarginPropertyName = this._secondIsSidebar ? "margin-bottom" : "margin-top"; |
| 519 | 518 |
| 520 var marginFrom = reverse ? "0" : "-" + WebInspector.zoomManager.dipToCSS (this._sidebarSizeDIP) + "px"; | 519 var marginFrom = reverse ? "0" : "-" + WebInspector.zoomManager.dipToCSS (this._sidebarSizeDIP) + "px"; |
| 521 var marginTo = reverse ? "-" + WebInspector.zoomManager.dipToCSS(this._s idebarSizeDIP) + "px" : "0"; | 520 var marginTo = reverse ? "-" + WebInspector.zoomManager.dipToCSS(this._s idebarSizeDIP) + "px" : "0"; |
| 522 | 521 |
| 523 // This order of things is important. | 522 this.contentElement.style.setProperty(animatedMarginPropertyName, margin To); |
| 524 // 1. Resize main element early and force layout. | 523 var keyframes = [{}, {}]; |
| 525 this.contentElement.style.setProperty(animatedMarginPropertyName, margin From); | 524 keyframes[0][animatedMarginPropertyName] = marginFrom; |
| 526 if (!reverse) { | 525 keyframes[1][animatedMarginPropertyName] = marginTo; |
| 527 suppressUnused(this._mainElement.offsetWidth); | 526 var player = this.contentElement.animate(keyframes, { duration: 150, eas ing: "cubic-bezier(0, 0, 0.2, 1)" }); |
| 528 suppressUnused(this._sidebarElement.offsetWidth); | 527 player.onfinish = this._cancelAnimation.bind(this); |
| 529 } | |
| 530 | |
| 531 // 2. Issue onresize to the sidebar element, its size won't change. | |
| 532 if (!reverse) | |
| 533 this._sidebarWidget.doResize(); | |
| 534 | |
| 535 // 3. Configure and run animation | |
| 536 this.contentElement.style.setProperty("transition", animatedMarginProper tyName + " " + animationTime + "ms linear"); | |
| 537 | |
| 538 var boundAnimationFrame; | |
| 539 var startTime; | |
| 540 /** | |
| 541 * @this {WebInspector.SplitWidget} | |
| 542 */ | |
| 543 function animationFrame() | |
| 544 { | |
| 545 delete this._animationFrameHandle; | |
| 546 | |
| 547 if (!startTime) { | |
| 548 // Kick animation on first frame. | |
| 549 this.contentElement.style.setProperty(animatedMarginPropertyName , marginTo); | |
| 550 startTime = window.performance.now(); | |
| 551 } else if (window.performance.now() < startTime + animationTime) { | |
| 552 // Process regular animation frame. | |
| 553 if (this._mainWidget) | |
| 554 this._mainWidget.doResize(); | |
|
pfeldman
2015/05/26 06:01:14
It might be important to make this call.
samli
2015/05/26 07:22:43
Done.
| |
| 555 } else { | |
| 556 // Complete animation. | |
| 557 this._cancelAnimation(); | |
| 558 if (this._mainWidget) | |
| 559 this._mainWidget.doResize(); | |
|
pfeldman
2015/05/26 06:01:14
It is definitely important to make this call.
samli
2015/05/26 07:22:43
In some cases, this is handled in the callback().
| |
| 560 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.Si debarSizeChanged, this.sidebarSize()); | |
| 561 return; | |
| 562 } | |
| 563 this._animationFrameHandle = this.contentElement.window().requestAni mationFrame(boundAnimationFrame); | |
| 564 } | |
| 565 boundAnimationFrame = animationFrame.bind(this); | |
| 566 this._animationFrameHandle = this.contentElement.window().requestAnimati onFrame(boundAnimationFrame); | |
| 567 }, | 528 }, |
| 568 | 529 |
| 569 _cancelAnimation: function() | 530 _cancelAnimation: function() |
| 570 { | 531 { |
| 571 this.contentElement.style.removeProperty("margin-top"); | 532 this.contentElement.style.removeProperty("margin-top"); |
| 572 this.contentElement.style.removeProperty("margin-right"); | 533 this.contentElement.style.removeProperty("margin-right"); |
| 573 this.contentElement.style.removeProperty("margin-bottom"); | 534 this.contentElement.style.removeProperty("margin-bottom"); |
| 574 this.contentElement.style.removeProperty("margin-left"); | 535 this.contentElement.style.removeProperty("margin-left"); |
| 575 this.contentElement.style.removeProperty("transition"); | 536 this.contentElement.style.removeProperty("transition"); |
| 576 | 537 |
| 577 if (this._animationFrameHandle) { | |
| 578 this.contentElement.window().cancelAnimationFrame(this._animationFra meHandle); | |
| 579 delete this._animationFrameHandle; | |
| 580 } | |
| 581 if (this._animationCallback) { | 538 if (this._animationCallback) { |
| 582 this._animationCallback(); | 539 this._animationCallback(); |
| 583 delete this._animationCallback; | 540 delete this._animationCallback; |
| 584 } | 541 } |
| 585 }, | 542 }, |
| 586 | 543 |
| 587 /** | 544 /** |
| 588 * @param {number} sidebarSize | 545 * @param {number} sidebarSize |
| 589 * @param {boolean=} userAction | 546 * @param {boolean=} userAction |
| 590 * @return {number} | 547 * @return {number} |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 this._showHideSidebarButton.classList.toggle("toggled-hide", !sidebarHid den); | 847 this._showHideSidebarButton.classList.toggle("toggled-hide", !sidebarHid den); |
| 891 this._showHideSidebarButton.classList.toggle("top-sidebar-show-hide-butt on", !this.isVertical() && !this.isSidebarSecond()); | 848 this._showHideSidebarButton.classList.toggle("top-sidebar-show-hide-butt on", !this.isVertical() && !this.isSidebarSecond()); |
| 892 this._showHideSidebarButton.classList.toggle("right-sidebar-show-hide-bu tton", this.isVertical() && this.isSidebarSecond()); | 849 this._showHideSidebarButton.classList.toggle("right-sidebar-show-hide-bu tton", this.isVertical() && this.isSidebarSecond()); |
| 893 this._showHideSidebarButton.classList.toggle("bottom-sidebar-show-hide-b utton", !this.isVertical() && this.isSidebarSecond()); | 850 this._showHideSidebarButton.classList.toggle("bottom-sidebar-show-hide-b utton", !this.isVertical() && this.isSidebarSecond()); |
| 894 this._showHideSidebarButton.classList.toggle("left-sidebar-show-hide-but ton", this.isVertical() && !this.isSidebarSecond()); | 851 this._showHideSidebarButton.classList.toggle("left-sidebar-show-hide-but ton", this.isVertical() && !this.isSidebarSecond()); |
| 895 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s" , this._showHideSidebarButtonTitle); | 852 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s" , this._showHideSidebarButtonTitle); |
| 896 }, | 853 }, |
| 897 | 854 |
| 898 __proto__: WebInspector.Widget.prototype | 855 __proto__: WebInspector.Widget.prototype |
| 899 } | 856 } |
| OLD | NEW |