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

Side by Side Diff: ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js

Issue 2815623005: MD Settings: in cr_dialog, prevent intersectionObserver from firing early. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 'cr-dialog' is a component for showing a modal dialog. If the 6 * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the
7 * dialog is closed via close(), a 'close' event is fired. If the dialog is 7 * dialog is closed via close(), a 'close' event is fired. If the dialog is
8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event. 8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event.
9 * Additionally clients can inspect the dialog's |returnValue| property inside 9 * Additionally clients can inspect the dialog's |returnValue| property inside
10 * the 'close' event listener to determine whether it was canceled or just 10 * the 'close' event listener to determine whether it was canceled or just
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 assert(target == bottomMarker || target == topMarker); 76 assert(target == bottomMarker || target == topMarker);
77 77
78 var classToToggle = 78 var classToToggle =
79 target == bottomMarker ? 'bottom-scrollable' : 'top-scrollable'; 79 target == bottomMarker ? 'bottom-scrollable' : 'top-scrollable';
80 80
81 bodyContainer.classList.toggle( 81 bodyContainer.classList.toggle(
82 classToToggle, entries[i].intersectionRatio == 0); 82 classToToggle, entries[i].intersectionRatio == 0);
83 } 83 }
84 }; 84 };
85 85
86 this.intersectionObserver_ = new IntersectionObserver( 86 this.intersectionObserver_ = new IntersectionObserver(
Dan Beam 2017/04/12 01:09:43 note: you might want to do this inside of your aft
scottchen 2017/04/12 01:43:05 Done. Also moved the contained code to a separate
87 callback, 87 callback,
88 /** @type {IntersectionObserverInit} */ ({ 88 /** @type {IntersectionObserverInit} */ ({
89 root: bodyContainer, 89 root: bodyContainer,
90 threshold: 0, 90 threshold: 0,
91 })); 91 }));
92 this.intersectionObserver_.observe(bottomMarker); 92
93 this.intersectionObserver_.observe(topMarker); 93 // Make sure the handler isn't triggered before the dialog is rendered.
94 Polymer.RenderStatus.afterNextRender(this, function() {
dpapad 2017/04/12 01:05:51 Should we be calling observe() in ready() instead?
Dan Beam 2017/04/12 01:07:13 i'm fairly sure that attached() happens after read
scottchen 2017/04/12 01:43:05 Yep, attached() fires after ready(). Not sure if i
95 this.intersectionObserver_.observe(bottomMarker);
96 this.intersectionObserver_.observe(topMarker);
97 });
94 } 98 }
95 }, 99 },
96 100
97 /** @override */ 101 /** @override */
98 detached: function() { 102 detached: function() {
99 if (this.intersectionObserver_) { 103 if (this.intersectionObserver_) {
100 this.intersectionObserver_.disconnect(); 104 this.intersectionObserver_.disconnect();
101 this.intersectionObserver_ = null; 105 this.intersectionObserver_ = null;
102 } 106 }
103 }, 107 },
(...skipping 29 matching lines...) Expand all
133 return; 137 return;
134 138
135 var actionButton = 139 var actionButton =
136 this.querySelector('.action-button:not([disabled]):not([hidden])'); 140 this.querySelector('.action-button:not([disabled]):not([hidden])');
137 if (actionButton) { 141 if (actionButton) {
138 actionButton.click(); 142 actionButton.click();
139 e.preventDefault(); 143 e.preventDefault();
140 } 144 }
141 }, 145 },
142 }); 146 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698