| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 This implements a splitter element which can be used to resize | 6 * @fileoverview This implements a splitter element which can be used to resize |
| 7 * elements in split panes. | 7 * elements in split panes. |
| 8 * | 8 * |
| 9 * The parent of the splitter should be an hbox (display: -webkit-box) with at | 9 * The parent of the splitter should be an hbox (display: -webkit-box) with at |
| 10 * least one previous element sibling. The splitter controls the width of the | 10 * least one previous element sibling. The splitter controls the width of the |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 this.endDrag_(); | 226 this.endDrag_(); |
| 227 }, | 227 }, |
| 228 | 228 |
| 229 /** | 229 /** |
| 230 * Handles start of the splitter dragging. Saves current width of the | 230 * Handles start of the splitter dragging. Saves current width of the |
| 231 * element being resized. | 231 * element being resized. |
| 232 * @protected | 232 * @protected |
| 233 */ | 233 */ |
| 234 handleSplitterDragStart: function() { | 234 handleSplitterDragStart: function() { |
| 235 // Use the computed width style as the base so that we can ignore what | 235 // Use the computed width style as the base so that we can ignore what |
| 236 // box sizing the element has. | 236 // box sizing the element has. Add the difference between offset and |
| 237 // client widths to account for any scrollbars. |
| 237 var targetElement = this.getResizeTarget_(); | 238 var targetElement = this.getResizeTarget_(); |
| 238 var doc = targetElement.ownerDocument; | 239 var doc = targetElement.ownerDocument; |
| 239 this.startWidth_ = | 240 this.startWidth_ = |
| 240 parseFloat(doc.defaultView.getComputedStyle(targetElement).width); | 241 parseFloat(doc.defaultView.getComputedStyle(targetElement).width) + |
| 242 targetElement.offsetWidth - targetElement.clientWidth; |
| 241 }, | 243 }, |
| 242 | 244 |
| 243 /** | 245 /** |
| 244 * Handles splitter moves. Updates width of the element being resized. | 246 * Handles splitter moves. Updates width of the element being resized. |
| 245 * @param {number} deltaX The change of splitter horizontal position. | 247 * @param {number} deltaX The change of splitter horizontal position. |
| 246 * @protected | 248 * @protected |
| 247 */ | 249 */ |
| 248 handleSplitterDragMove: function(deltaX) { | 250 handleSplitterDragMove: function(deltaX) { |
| 249 var targetElement = this.getResizeTarget_(); | 251 var targetElement = this.getResizeTarget_(); |
| 250 var newWidth = this.startWidth_ + this.calcDeltaX_(deltaX); | 252 var newWidth = this.startWidth_ + this.calcDeltaX_(deltaX); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 263 var doc = targetElement.ownerDocument; | 265 var doc = targetElement.ownerDocument; |
| 264 var computedWidth = | 266 var computedWidth = |
| 265 parseFloat(doc.defaultView.getComputedStyle(targetElement).width); | 267 parseFloat(doc.defaultView.getComputedStyle(targetElement).width); |
| 266 if (this.startWidth_ != computedWidth) | 268 if (this.startWidth_ != computedWidth) |
| 267 cr.dispatchSimpleEvent(this, 'resize'); | 269 cr.dispatchSimpleEvent(this, 'resize'); |
| 268 }, | 270 }, |
| 269 }; | 271 }; |
| 270 | 272 |
| 271 return {Splitter: Splitter}; | 273 return {Splitter: Splitter}; |
| 272 }); | 274 }); |
| OLD | NEW |