OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 // We can't pass the currently dragging tile via dataTransfer because of | 8 // We can't pass the currently dragging tile via dataTransfer because of |
9 // http://crbug.com/31037 | 9 // http://crbug.com/31037 |
10 var currentlyDraggingTile = null; | 10 var currentlyDraggingTile = null; |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 }, | 786 }, |
787 | 787 |
788 /** | 788 /** |
789 * Does the work of calculating the visibility, height and position of the | 789 * Does the work of calculating the visibility, height and position of the |
790 * scrollbar thumb (there is no track or buttons). | 790 * scrollbar thumb (there is no track or buttons). |
791 */ | 791 */ |
792 doUpdateScrollbars_: function() { | 792 doUpdateScrollbars_: function() { |
793 this.scrollbarUpdate_ = 0; | 793 this.scrollbarUpdate_ = 0; |
794 | 794 |
795 var content = this.content_; | 795 var content = this.content_; |
796 if (content.scrollHeight == content.clientHeight) { | 796 |
| 797 // Adjust height to account for possible header-bar. |
| 798 var adjustedClientHeight = content.clientHeight - content.offsetTop; |
| 799 |
| 800 if (content.scrollHeight == adjustedClientHeight) { |
797 this.scrollbar_.hidden = true; | 801 this.scrollbar_.hidden = true; |
798 return; | 802 return; |
799 } else { | 803 } else { |
800 this.scrollbar_.hidden = false; | 804 this.scrollbar_.hidden = false; |
801 } | 805 } |
802 | 806 |
803 var thumbTop = content.scrollTop / content.scrollHeight * | 807 var thumbTop = content.offsetTop + |
804 this.clientHeight; | 808 content.scrollTop / content.scrollHeight * adjustedClientHeight; |
805 var thumbHeight = content.clientHeight / content.scrollHeight * | 809 var thumbHeight = adjustedClientHeight / content.scrollHeight * |
806 this.clientHeight; | 810 this.clientHeight; |
807 | 811 |
808 this.scrollbar_.style.top = thumbTop + 'px'; | 812 this.scrollbar_.style.top = thumbTop + 'px'; |
809 this.scrollbar_.style.height = thumbHeight + 'px'; | 813 this.scrollbar_.style.height = thumbHeight + 'px'; |
810 }, | 814 }, |
811 | 815 |
812 /** | 816 /** |
813 * Get the height for a tile of a certain width. Override this function to | 817 * Get the height for a tile of a certain width. Override this function to |
814 * get non-square tiles. | 818 * get non-square tiles. |
815 * @param {number} width The pixel width of a tile. | 819 * @param {number} width The pixel width of a tile. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 */ | 1009 */ |
1006 tileMoved: function(draggedTile) { | 1010 tileMoved: function(draggedTile) { |
1007 }, | 1011 }, |
1008 }; | 1012 }; |
1009 | 1013 |
1010 return { | 1014 return { |
1011 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1015 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
1012 TilePage: TilePage, | 1016 TilePage: TilePage, |
1013 }; | 1017 }; |
1014 }); | 1018 }); |
OLD | NEW |