For my project, I have been provided with a JSON object that contains various settings, some being strings and others booleans.
One thing I am struggling with is adding an animation name from the object that is stored in a variable.
aniFx.move(inner, {
duration: 1,
delta: aniFx.ease.bouncePast
});
Explanation
Inner: document.getElementById('inner');
Duration: time multiplied by 1000 in my animation script (aniFx)
Delta: Animation used for moving the inner element
Everything works perfectly fine until I try to set delta
from the JSON object.
Let's say, hypothetically, my JSON object only contains the following:
_userObj = JSON.parse('{ "137340": { "effect": "aniFx.ease.swingTo" } }');
Now, why am I experiencing difficulties when trying this:
aniFx.move(inner, {
duration: 1,
delta: _userObj['137340'].effect
});
Upon triggering the function, I encounter the following error...
Console will return:
console.log => aniFx.ease.swingTo
aniFx.move => Uncaught TypeError: string is not a function