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

Side by Side Diff: chrome/browser/resources/file_manager/js/scrollbar.js

Issue 15761006: Files.app: Prevent a scroolbar from overshooting the border of the view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Creates a new scroll bar element. 8 * Creates a new scroll bar element.
9 * @extends {HTMLDivElement} 9 * @extends {HTMLDivElement}
10 * @constructor 10 * @constructor
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (!event.which) { 145 if (!event.which) {
146 this.onMouseUp_(event); 146 this.onMouseUp_(event);
147 return; 147 return;
148 } 148 }
149 var clientSize = this.clientHeight_; 149 var clientSize = this.clientHeight_;
150 var totalSize = this.scrollHeight_; 150 var totalSize = this.scrollHeight_;
151 var buttonSize = Math.max(50, clientSize / totalSize * clientSize); 151 var buttonSize = Math.max(50, clientSize / totalSize * clientSize);
152 152
153 var buttonPosition = this.buttonPressedPosition_ + 153 var buttonPosition = this.buttonPressedPosition_ +
154 (event.screenY - this.buttonPressedEvent_.screenY); 154 (event.screenY - this.buttonPressedEvent_.screenY);
155 // Ensures the scrollbar is in the view.
156 buttonPosition =
157 Math.max(0, Math.min(buttonPosition, clientSize - buttonSize));
155 var scrollPosition = totalSize * (buttonPosition / clientSize); 158 var scrollPosition = totalSize * (buttonPosition / clientSize);
156 159
157 this.scrollTop_ = scrollPosition; 160 this.scrollTop_ = scrollPosition;
158 this.view_.scrollTop = scrollPosition; 161 this.view_.scrollTop = scrollPosition;
159 this.redraw_(); 162 this.redraw_();
160 }; 163 };
161 164
162 /** 165 /**
163 * Handles changed in Dom by redrawing the scrollbar. Ignores consecutive calls. 166 * Handles changed in Dom by redrawing the scrollbar. Ignores consecutive calls.
164 * @private 167 * @private
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 requestAnimationFrame(function() { 203 requestAnimationFrame(function() {
201 this.hidden = hidden; 204 this.hidden = hidden;
202 this.button_.style.top = buttonTop + 'px'; 205 this.button_.style.top = buttonTop + 'px';
203 this.button_.style.height = buttonSize + 'px'; 206 this.button_.style.height = buttonSize + 'px';
204 }.bind(this)); 207 }.bind(this));
205 } 208 }
206 209
207 this.lastButtonTop_ = buttonTop; 210 this.lastButtonTop_ = buttonTop;
208 this.lastButtonSize_ = buttonSize; 211 this.lastButtonSize_ = buttonSize;
209 }; 212 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698