| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of touch; | 5 part of touch; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Implementation of a custom scrolling behavior. | 8 * Implementation of a custom scrolling behavior. |
| 9 * This behavior overrides native scrolling for an area. This area can be a | 9 * This behavior overrides native scrolling for an area. This area can be a |
| 10 * single defined part of a page, the entire page, or several different parts | 10 * single defined part of a page, the entire page, or several different parts |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 break; | 226 break; |
| 227 */ | 227 */ |
| 228 } | 228 } |
| 229 if (handled) { | 229 if (handled) { |
| 230 e.preventDefault(); | 230 e.preventDefault(); |
| 231 } | 231 } |
| 232 }); | 232 }); |
| 233 // The scrollable element must be relatively positioned. | 233 // The scrollable element must be relatively positioned. |
| 234 // TODO(jacobr): this assert fires asynchronously which could be confusing. | 234 // TODO(jacobr): this assert fires asynchronously which could be confusing. |
| 235 if (_scrollTechnique == ScrollerScrollTechnique.RELATIVE_POSITIONING) { | 235 if (_scrollTechnique == ScrollerScrollTechnique.RELATIVE_POSITIONING) { |
| 236 _element.computedStyle.then((CssStyleDeclaration style) { | 236 assert(_element.getComputedStyle().position != "static"); |
| 237 assert(style.position != "static"); | |
| 238 }); | |
| 239 } | 237 } |
| 240 | 238 |
| 241 _initLayer(); | 239 _initLayer(); |
| 242 } | 240 } |
| 243 | 241 |
| 244 EventListenerList get onScrollerStart { | 242 EventListenerList get onScrollerStart { |
| 245 if (_onScrollerStart == null) { | 243 if (_onScrollerStart == null) { |
| 246 _onScrollerStart = new SimpleEventListenerList(); | 244 _onScrollerStart = new SimpleEventListenerList(); |
| 247 } | 245 } |
| 248 return _onScrollerStart; | 246 return _onScrollerStart; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 _minOffset.x = 0; | 534 _minOffset.x = 0; |
| 537 _minOffset.y = 0; | 535 _minOffset.y = 0; |
| 538 reconfigure(() => _setContentOffset(_maxPoint.x, _maxPoint.y)); | 536 reconfigure(() => _setContentOffset(_maxPoint.x, _maxPoint.y)); |
| 539 } | 537 } |
| 540 | 538 |
| 541 /** | 539 /** |
| 542 * Recalculate dimensions of the frame and the content. Adjust the minPoint | 540 * Recalculate dimensions of the frame and the content. Adjust the minPoint |
| 543 * and maxPoint allowed for scrolling. | 541 * and maxPoint allowed for scrolling. |
| 544 */ | 542 */ |
| 545 void _resize(Callback callback) { | 543 void _resize(Callback callback) { |
| 546 window.requestLayoutFrame(() { | 544 window.setImmediate(() { |
| 547 if (_lookupContentSizeDelegate != null) { | 545 if (_lookupContentSizeDelegate != null) { |
| 548 _contentSize = _lookupContentSizeDelegate(); | 546 _contentSize = _lookupContentSizeDelegate(); |
| 549 } else { | 547 } else { |
| 550 _contentSize = new Size(_element.scrollWidth, _element.scrollHeight); | 548 _contentSize = new Size(_element.scrollWidth, _element.scrollHeight); |
| 551 } | 549 } |
| 552 | 550 |
| 553 _scrollSize = new Size(_frame.offsetWidth, | 551 _scrollSize = new Size(_frame.offsetWidth, |
| 554 _frame.offsetHeight); | 552 _frame.offsetHeight); |
| 555 Size adjusted = _getAdjustedContentSize(); | 553 Size adjusted = _getAdjustedContentSize(); |
| 556 _maxPoint = new Coordinate(-_maxOffset.x, -_maxOffset.y); | 554 _maxPoint = new Coordinate(-_maxOffset.x, -_maxOffset.y); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 for (EventListener listener in _listeners) { | 713 for (EventListener listener in _listeners) { |
| 716 listener(evt); | 714 listener(evt); |
| 717 } | 715 } |
| 718 } | 716 } |
| 719 } | 717 } |
| 720 | 718 |
| 721 class ScrollerScrollTechnique { | 719 class ScrollerScrollTechnique { |
| 722 static const TRANSFORM_3D = 1; | 720 static const TRANSFORM_3D = 1; |
| 723 static const RELATIVE_POSITIONING = 2; | 721 static const RELATIVE_POSITIONING = 2; |
| 724 } | 722 } |
| OLD | NEW |