From f466703c100800a11310db289693bc0ef0f138dc Mon Sep 17 00:00:00 2001 From: abe33 Date: Thu, 2 Apr 2015 16:12:59 +0200 Subject: [PATCH] :racehorse: Register to styles changes only after being attached It limits the amount of events an element receives on startup. --- lib/minimap-element.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index ed6349ef..a5dc2f25 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -40,15 +40,6 @@ class MinimapElement extends HTMLElement @subscriptions = new CompositeDisposable @initializeContent() - # Uses of `atom.styles.onDidAddStyleElement` instead of - # `atom.themes.onDidChangeActiveThemes`. - # Why? - # Currently, The styleElement will be removed first, - # and then re-add. So the `change` event has not be triggered. - @subscriptions.add atom.styles.onDidAddStyleElement => - @invalidateCache() - @requestForcedUpdate() - @observeConfig 'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) => swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft @@ -89,6 +80,15 @@ class MinimapElement extends HTMLElement @measureHeightAndWidth() @attached = true + # Uses of `atom.styles.onDidAddStyleElement` instead of + # `atom.themes.onDidChangeActiveThemes`. + # Why? + # Currently, The styleElement will be removed first, + # and then re-add. So the `change` event has not be triggered. + @subscriptions.add atom.styles.onDidAddStyleElement => + @invalidateCache() + @requestForcedUpdate() + # Internal: DOM callback invoked when a new {MinimapElement} is detached # from the DOM. detachedCallback: ->