summaryrefslogtreecommitdiff
path: root/src/config.js
blob: c306d8f9b0a02b954343451cdf44afe091f3a1eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const config = {
  selector: '[data-libra]',
  margin: 50,
  offset: { x: 0, y: 0 },
  transitionDuration: 200, // milliseconds
  imageCursor: 'zoom-in',
};

function deepMerge(target, source) {
  for (const key in source) {
    if (
      typeof source[key] === 'object' &&
      source[key] !== null &&
      !Array.isArray(source[key])
    ) {
      if (!target[key]) target[key] = {};
      deepMerge(target[key], source[key]);
    } else {
      target[key] = source[key];
    }
  }
  return target;
}

export function setConfig(newConfig) {
  deepMerge(config, newConfig);
}

export default config;