Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 "use strict"; | 1 "use strict"; |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 | 1515 |
| 1516 | 1516 |
| 1517 /** | 1517 /** |
| 1518 * @param {!number} value | 1518 * @param {!number} value |
| 1519 */ | 1519 */ |
| 1520 ScrollView.prototype.setContentOffset = function(value) { | 1520 ScrollView.prototype.setContentOffset = function(value) { |
| 1521 console.assert(isFinite(value)); | 1521 console.assert(isFinite(value)); |
| 1522 value = Math.min(this.maximumContentOffset - this._height, Math.max(this.min imumContentOffset, Math.floor(value))); | 1522 value = Math.min(this.maximumContentOffset - this._height, Math.max(this.min imumContentOffset, Math.floor(value))); |
| 1523 if (this._contentOffset === value) | 1523 if (this._contentOffset === value) |
| 1524 return; | 1524 return; |
| 1525 var newPartitionNumber = Math.floor(value / ScrollView.PartitionHeight); | 1525 var partitionChanged = this._updateScrollContent(value); |
|
keishi
2014/03/14 10:51:07
Set this._contentOffset before calling _updateScro
Habib Virji
2014/03/14 11:18:36
Done.
| |
| 1526 var partitionChanged = this._partitionNumber !== newPartitionNumber; | |
| 1527 this._partitionNumber = newPartitionNumber; | |
| 1528 this._contentOffset = value; | 1526 this._contentOffset = value; |
| 1529 this.contentElement.style.webkitTransform = "translate(0, " + (-this.content PositionForContentOffset(this._contentOffset)) + "px)"; | |
| 1530 if (this.delegate) { | 1527 if (this.delegate) { |
| 1531 this.delegate.scrollViewDidChangeContentOffset(this); | 1528 this.delegate.scrollViewDidChangeContentOffset(this); |
| 1532 if (partitionChanged) | 1529 if (partitionChanged) |
| 1533 this.delegate.scrollViewDidChangePartition(this); | 1530 this.delegate.scrollViewDidChangePartition(this); |
|
keishi
2014/03/14 10:51:07
This should be called inside _updateScrollContent.
Habib Virji
2014/03/14 11:18:36
Done.
| |
| 1534 } | 1531 } |
| 1535 }; | 1532 }; |
| 1536 | 1533 |
| 1537 /** | 1534 /** |
| 1535 * @param {!number} value | |
| 1536 * @return {!number} partitionChanged | |
| 1537 */ | |
| 1538 ScrollView.prototype._updateScrollContent = function(value) { | |
| 1539 var newPartitionNumber = Math.floor(value / ScrollView.PartitionHeight); | |
| 1540 var partitionChanged = this._partitionNumber !== newPartitionNumber; | |
| 1541 this._partitionNumber = newPartitionNumber; | |
| 1542 this.contentElement.style.webkitTransform = "translate(0, " + (-this.content PositionForContentOffset(value)) + "px)"; | |
| 1543 return partitionChanged; | |
| 1544 }; | |
| 1545 | |
| 1546 /** | |
| 1547 * @param {!View|Node} parent | |
| 1548 * @param {?View|Node=} before | |
| 1549 * @override | |
| 1550 */ | |
| 1551 ScrollView.prototype.attachTo = function(parent, before) { | |
| 1552 View.prototype.attachTo.call(this, parent, before); | |
| 1553 this._updateScrollContent(this._contentOffset); | |
| 1554 }; | |
| 1555 | |
| 1556 /** | |
| 1538 * @param {!number} offset | 1557 * @param {!number} offset |
| 1539 */ | 1558 */ |
| 1540 ScrollView.prototype.contentPositionForContentOffset = function(offset) { | 1559 ScrollView.prototype.contentPositionForContentOffset = function(offset) { |
| 1541 return offset - this._partitionNumber * ScrollView.PartitionHeight; | 1560 return offset - this._partitionNumber * ScrollView.PartitionHeight; |
| 1542 }; | 1561 }; |
| 1543 | 1562 |
| 1544 /** | 1563 /** |
| 1545 * @constructor | 1564 * @constructor |
| 1546 * @extends View | 1565 * @extends View |
| 1547 */ | 1566 */ |
| (...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4025 event.stopPropagation(); | 4044 event.stopPropagation(); |
| 4026 event.preventDefault(); | 4045 event.preventDefault(); |
| 4027 } | 4046 } |
| 4028 } | 4047 } |
| 4029 | 4048 |
| 4030 if (window.dialogArguments) { | 4049 if (window.dialogArguments) { |
| 4031 initialize(dialogArguments); | 4050 initialize(dialogArguments); |
| 4032 } else { | 4051 } else { |
| 4033 window.addEventListener("message", handleMessage, false); | 4052 window.addEventListener("message", handleMessage, false); |
| 4034 } | 4053 } |
| OLD | NEW |