Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview A helper object to be used when an iron-list needs to be aware | |
| 7 * of a global scroll target. | |
|
michaelpg
2016/10/19 19:50:09
I'd add a little more instruction here, e.g. that
hcarmona
2016/10/20 14:27:44
Done.
| |
| 8 */ | |
| 9 | |
| 10 /** | |
| 11 * Global object to hold the scroll target. | |
| 12 * @type {{ | |
| 13 * targetPromise: (Promise<HTMLElement>|undefined), | |
| 14 * fulfillPromise: (function(HTMLElement)|undefined), | |
| 15 * }} | |
| 16 */ | |
| 17 global.settingsScrollTargetData = {}; | |
|
michaelpg
2016/10/19 19:50:09
where does |global| actually come from? dunno why
hcarmona
2016/10/20 14:27:44
|global| is defined here: https://cs.chromium.org/
| |
| 18 /** @type {Promise<HTMLElement>} */ | |
| 19 global.settingsScrollTargetData.targetPromise = new Promise(function(accept) { | |
|
michaelpg
2016/10/19 19:50:09
Would our PromiseResolver be more convenient?
hcarmona
2016/10/20 14:27:44
Yes
| |
| 20 global.settingsScrollTargetData.fulfillPromise = accept; | |
| 21 }); | |
| 22 | |
| 23 /** @polymerBehavior */ | |
| 24 var GlobalScrollTargetBehavior = { | |
| 25 properties: { | |
| 26 /** | |
| 27 * Read only property for the scroll target. | |
| 28 * @type {HTMLElement} | |
| 29 */ | |
| 30 scrollTarget: { | |
| 31 type: Object, | |
| 32 notify: true, | |
|
michaelpg
2016/10/19 19:50:09
Shouldn't need notify: true; as we're not 2-way bi
hcarmona
2016/10/20 14:27:44
Done.
| |
| 33 readOnly: true, | |
| 34 }, | |
| 35 }, | |
| 36 | |
| 37 /** | |
| 38 * Reference to the global data. This allows Polymer style data binding. | |
|
michaelpg
2016/10/19 19:50:08
comment outdated
hcarmona
2016/10/20 14:27:44
Acknowledged.
| |
| 39 * @type {{ | |
| 40 * targetPromise: (Promise<HTMLElement>|undefined), | |
|
michaelpg
2016/10/19 19:50:09
make a typedef instead of copying/pasting
hcarmona
2016/10/20 14:27:44
Acknowledged.
| |
| 41 * fulfillPromise: (function(HTMLElement)|undefined), | |
| 42 * }} | |
| 43 * @private | |
| 44 */ | |
| 45 globalData_: global.settingsScrollTargetData, | |
| 46 | |
| 47 /** @override */ | |
| 48 attached: function() { | |
| 49 this.globalData_.targetPromise.then(function(scrollTarget) { | |
| 50 this._setScrollTarget(scrollTarget); | |
| 51 }.bind(this)); | |
| 52 }, | |
| 53 | |
| 54 /** | |
| 55 * This should only be called once. | |
| 56 * @param {HTMLElement} value | |
| 57 */ | |
| 58 setGlobalScrollTarget: function(value) { | |
| 59 this.globalData_.fulfillPromise(value); | |
| 60 }, | |
| 61 }; | |
| OLD | NEW |