Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support export and import piling configuration #46

Open
flekschas opened this issue Nov 14, 2019 · 0 comments
Open

Support export and import piling configuration #46

flekschas opened this issue Nov 14, 2019 · 0 comments
Labels
new feature Coding: new feature or enhacement

Comments

@flekschas
Copy link
Owner

The piling configuration is a subset of the entire state. The idea is that one can export and save just the configuration for later reuse with different datasets.

Similar to exporting the entire state we would have to get the current state of the library. In addition, we need to define which property is considered part of the piling configuration and only keep those properties. Also for certain properties, we need to provide an efficient way of serializing functional parameters like easing.

On export, the easiest way to do the serialization is to check if the functional property is an internal property (e.g., state.easing === cubeInOut) and if so only return a string referencing this function (e.g., easing: 'cubeInOut'). Otherwise, we have to stringify the function (e.g., state.easing.toString().

On import, for functional properties, we have to check if the value represents some internal functions or if it's a stringified custom function. E.g.:

// Somewhere
var easingMap = new Map();
easingMap.set('cubeInOut', cubeInOut);

// In the import function
set({
  ...import,
  easing: easingMap.has(import.easing)
    ? easingMap(import.easing)
    : eval(`(${import.easing})`)
});
@flekschas flekschas added the new feature Coding: new feature or enhacement label Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Coding: new feature or enhacement
Projects
None yet
Development

No branches or pull requests

1 participant