From a88678fb70a124632ae29cbe36980ab3a2608e2d Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 24 Oct 2018 15:07:47 -0700 Subject: [PATCH] fix bad css merge, add particle property debounce --- scripts/system/html/css/edit-style.css | 2 +- scripts/system/html/js/entityProperties.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 5214dc0c3e..2db7fce065 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -1107,7 +1107,7 @@ body#entity-list-body { position: relative; /* New positioning context. */ } -#search-area { +#filter-area { padding-right: 168px; padding-bottom: 24px; } diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index db3424bbd9..676ecaf289 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1304,6 +1304,7 @@ const JSON_EDITOR_ROW_DIV_INDEX = 2; var elGroups = {}; var properties = {}; var colorPickers = {}; +var particlePropertyUpdates = {}; var selectedEntityProperties; var lastEntityID = null; @@ -1534,9 +1535,23 @@ function updateProperty(originalPropertyName, propertyValue) { } else { propertyUpdate[originalPropertyName] = propertyValue; } - updateProperties(propertyUpdate); + // queue up particle property changes with the debounced sync to avoid + // causing particle emitting to reset each frame when updating values + if (properties[originalPropertyName].isParticleProperty) { + Object.keys(propertyUpdate).forEach(function (propertyUpdateKey) { + particlePropertyUpdates[propertyUpdateKey] = propertyUpdate[propertyUpdateKey]; + }); + particleSyncDebounce(); + } else { + updateProperties(propertyUpdate); + } } +var particleSyncDebounce = _.debounce(function () { + updateProperties(particlePropertyUpdates); + particlePropertyUpdates = {}; +}, DEBOUNCE_TIMEOUT); + function updateProperties(propertiesToUpdate) { EventBridge.emitWebEvent(JSON.stringify({ id: lastEntityID, @@ -2717,7 +2732,8 @@ function loaded() { let property = { data: propertyData, elementID: propertyElementID, - name: propertyName, + name: propertyName, + isParticleProperty: group.id.includes("particles"), elProperty: elProperty }; properties[propertyID] = property;