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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js

Issue 1862213002: Roll third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete appearance_browsertest.js, result of a previous bad merge. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js
index 6ab3521e82241216d1408d317b9cdad7f1c22053..7e3f09a8f160f9f4992ad66959c07764330daa32 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-scroll-target-behavior/iron-scroll-target-behavior-extracted.js
@@ -15,20 +15,31 @@
/**
* Specifies the element that will handle the scroll event
- * on the behalf of the current element. This is typically a reference to an `Element`,
+ * on the behalf of the current element. This is typically a reference to an element,
* but there are a few more posibilities:
*
* ### Elements id
*
*```html
- * <div id="scrollable-element" style="overflow-y: auto;">
+ * <div id="scrollable-element" style="overflow: auto;">
* <x-element scroll-target="scrollable-element">
- * Content
+ * <!-- Content-->
* </x-element>
* </div>
*```
- * In this case, `scrollTarget` will point to the outer div element. Alternatively,
- * you can set the property programatically:
+ * In this case, the `scrollTarget` will point to the outer div element.
+ *
+ * ### Document scrolling
+ *
+ * For document scrolling, you can use the reserved word `document`:
+ *
+ *```html
+ * <x-element scroll-target="document">
+ * <!-- Content -->
+ * </x-element>
+ *```
+ *
+ * ### Elements reference
*
*```js
* appHeader.scrollTarget = document.querySelector('#scrollable-element');
@@ -49,42 +60,39 @@
],
_scrollTargetChanged: function(scrollTarget, isAttached) {
- // Remove lister to the current scroll target
+ var eventTarget;
+
if (this._oldScrollTarget) {
- if (this._oldScrollTarget === this._doc) {
- window.removeEventListener('scroll', this._boundScrollHandler);
- } else if (this._oldScrollTarget.removeEventListener) {
- this._oldScrollTarget.removeEventListener('scroll', this._boundScrollHandler);
- }
+ eventTarget = this._oldScrollTarget === this._doc ? window : this._oldScrollTarget;
+ eventTarget.removeEventListener('scroll', this._boundScrollHandler);
this._oldScrollTarget = null;
}
- if (isAttached) {
- // Support element id references
- if (typeof scrollTarget === 'string') {
-
- var host = this.domHost;
- this.scrollTarget = host && host.$ ? host.$[scrollTarget] :
- Polymer.dom(this.ownerDocument).querySelector('#' + scrollTarget);
-
- } else if (this._scrollHandler) {
-
- this._boundScrollHandler = this._boundScrollHandler || this._scrollHandler.bind(this);
- // Add a new listener
- if (scrollTarget === this._doc) {
- window.addEventListener('scroll', this._boundScrollHandler);
- if (this._scrollTop !== 0 || this._scrollLeft !== 0) {
- this._scrollHandler();
- }
- } else if (scrollTarget && scrollTarget.addEventListener) {
- scrollTarget.addEventListener('scroll', this._boundScrollHandler);
- }
- this._oldScrollTarget = scrollTarget;
- }
+
+ if (!isAttached) {
+ return;
+ }
+ // Support element id references
+ if (scrollTarget === 'document') {
+
+ this.scrollTarget = this._doc;
+
+ } else if (typeof scrollTarget === 'string') {
+
+ this.scrollTarget = this.domHost ? this.domHost.$[scrollTarget] :
+ Polymer.dom(this.ownerDocument).querySelector('#' + scrollTarget);
+
+ } else if (this._isValidScrollTarget()) {
+
+ eventTarget = scrollTarget === this._doc ? window : scrollTarget;
+ this._boundScrollHandler = this._boundScrollHandler || this._scrollHandler.bind(this);
+ this._oldScrollTarget = scrollTarget;
+
+ eventTarget.addEventListener('scroll', this._boundScrollHandler);
}
},
/**
- * Runs on every scroll event. Consumer of this behavior may want to override this method.
+ * Runs on every scroll event. Consumer of this behavior may override this method.
*
* @protected
*/

Powered by Google App Engine
This is Rietveld 408576698