Skip to content

Commit

Permalink
remove improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSora committed Jun 10, 2024
1 parent 1b60e35 commit 285a939
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions packages/overlayscrollbars/src/setups/setups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const createSetups = (
onUpdated: (updateInfo: SetupsUpdateInfo, updateHints: SetupsUpdateHints) => void,
onScroll: (scrollEvent: Event) => void
): Setups => {
let cacheAndOptionsInitialized = false;
let cacheInitialized = false;
const getCurrentOption = createOptionCheck(options, {});
const [
structureSetupCreate,
Expand Down Expand Up @@ -116,6 +116,10 @@ export const createSetups = (
updateInfo: SetupsUpdateInfo,
observerUpdateHints?: ObserversSetupUpdateHints
): boolean => {
if (isDestroyed()) {
return false;
}

const {
_changedOptions: rawChangedOptions,
_force: rawForce,
Expand All @@ -124,42 +128,33 @@ export const createSetups = (
} = updateInfo;

const _changedOptions = rawChangedOptions || {};
const _force = !!rawForce || !cacheAndOptionsInitialized;
const _force = !!rawForce || !cacheInitialized;
const baseUpdateInfoObj: SetupUpdateInfo = {
_checkOption: createOptionCheck(options, _changedOptions, _force),
_changedOptions,
_force,
};
const hasChangedOptions = !isEmptyObject(_changedOptions);

if (isDestroyed()) {
return false;
}

if (_cloneScrollbar) {
scrollbarsSetupUpdate(baseUpdateInfoObj);
return false;
}

let changed = _force || hasChangedOptions;
let observersHints = {};
let structureHints = {};

// if (changed || hasDimensions(structureSetupElements._host)) {
observersHints =
const observersHints =
observerUpdateHints ||
observersSetupUpdate(
assignDeep({}, baseUpdateInfoObj, {
_takeRecords,
})
);

structureHints = structureSetupUpdate(
const structureHints = structureSetupUpdate(
assignDeep({}, baseUpdateInfoObj, {
_observersState: observersSetupState,
_observersUpdateHints: observersHints,
})
);

scrollbarsSetupUpdate(
assignDeep({}, baseUpdateInfoObj, {
_observersUpdateHints: observersHints,
Expand All @@ -169,17 +164,17 @@ export const createSetups = (

const truthyObserversHints = updateHintsAreTruthy(observersHints);
const truthyStructureHints = updateHintsAreTruthy(structureHints);
changed = changed || truthyObserversHints || truthyStructureHints;
// }
const changed =
truthyObserversHints || truthyStructureHints || !isEmptyObject(_changedOptions) || _force;

cacheInitialized = true;

changed &&
onUpdated(updateInfo, {
_observersUpdateHints: observersHints,
_structureUpdateHints: structureHints,
});

cacheAndOptionsInitialized = true;

return changed;
};

Expand Down

0 comments on commit 285a939

Please sign in to comment.