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

Unified Diff: ui/webui/resources/js/util.js

Issue 1811113003: Reduce failsafe time for animation events. This makes the lock-time more consistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Nit Created 4 years, 9 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
« no previous file with comments | « ui/login/account_picker/user_pod_row.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/util.js
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index 2707dbcdd25f12ec3d996f72d60fc049849293c5..82a4e50328d9af214dfc00c0ea84eed786be8a7f 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -374,10 +374,19 @@ function createElementWithClassName(type, className) {
* or when no paint happens during the animation). This function sets up
* a timer and emulate the event if it is not fired when the timer expires.
* @param {!HTMLElement} el The element to watch for webkitTransitionEnd.
- * @param {number} timeOut The maximum wait time in milliseconds for the
- * webkitTransitionEnd to happen.
+ * @param {number=} opt_timeOut The maximum wait time in milliseconds for the
+ * webkitTransitionEnd to happen. If not specified, it is fetched from |el|
+ * using the transitionDuration style value.
*/
-function ensureTransitionEndEvent(el, timeOut) {
+function ensureTransitionEndEvent(el, opt_timeOut) {
+ if (opt_timeOut === undefined) {
+ var style = getComputedStyle(el);
+ opt_timeOut = parseFloat(style.transitionDuration) * 1000;
+
+ // Give an additional 50ms buffer for the animation to complete.
+ opt_timeOut += 50;
+ }
+
var fired = false;
el.addEventListener('webkitTransitionEnd', function f(e) {
el.removeEventListener('webkitTransitionEnd', f);
@@ -386,7 +395,7 @@ function ensureTransitionEndEvent(el, timeOut) {
window.setTimeout(function() {
if (!fired)
cr.dispatchSimpleEvent(el, 'webkitTransitionEnd', true);
- }, timeOut);
+ }, opt_timeOut);
}
/**
« no previous file with comments | « ui/login/account_picker/user_pod_row.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698