-1
Have the variable below:
[object Object]
'0%' : [{ 'margin-left':'-0%'}],
'25%' : [{ 'margin-left':'-0%'}],
'30%' : [{ 'margin-left':'-100%'}],
'50%' : [{ 'margin-left':'-100%'}],
'55%' : [{ 'margin-left':'-200%'}],
'75%' : [{ 'margin-left':'-200%'}],
'80%' : [{ 'margin-left':'-300%'}],
'100%' : [{ 'margin-left':'-300%'}],
Brought by
console.log(imagem);
How to make it into a json object?
Where does that come from?
var tempoTransicao = 5;
var quantasImagens = $("div.slider ul.slide li img").size();
var tamanhoIntervalos = Math.round(100/quantasImagens);
var tempoImagens = 0;
var t = 0;
var imagem = "";
var imagens = {};
for (i = 0; i < quantasImagens; i++) {
tMin = t + tempoTransicao;
tMax = t + tamanhoIntervalos;
t+=tamanhoIntervalos;
if(i==0) tMin=0;
if(i==quantasImagens) tMax=100;
imagem += "'" + tMin + "%' : [{ 'margin-left':'-" + tempoImagens + "%'}],";
imagem += "'" + tMax + "%' : [{ 'margin-left':'-" + tempoImagens + "%'}],";
tempoImagens+=100;
}
$.keyframe.define([
$.extend(
{ name: 'tocaSlide' },
imagemjson
)
]);
Some mistake in this construction?
var jsonString = "{ \"0%\" : { \"margin-left\":\"-0%\"},";
jsonString += " \"25%\" : { \"margin-left\":\"-0%\"},";
jsonString += " \"30%\" : { \"margin-left\":\"-100%\"},";
jsonString += " \"50%\" : { \"margin-left\":\"-100%\"},";
jsonString += " \"55%\" : { \"margin-left\":\"-200%\"},";
jsonString += " \"75%\" : { \"margin-left\":\"-200%\"},";
jsonString += " \"80%\" : { \"margin-left\":\"-300%\"},";
jsonString += " \"100%\" : { \"margin-left\":\"-300%\"}}";
jsonString = JSON.parse(jsonString);
console.log(jsonString);
$.keyframe.define([
$.extend(
{ name: 'jsonString' },
jsonString
)
]);
Can you show where this string comes from? Just like this has a syntax error because Javascript does not allow line breaks inside strings...
– Sergio
yes, at the end of the question. the goal is to generate the json obj in the picture variable.
– Carlos Rocha
Now I’m even more curious: which application is this? or better: what is the functionality you want to create?
– Sergio
then, I want to use the function $.keyframe.define([, and put this json variable in as it is at the end of the question. The goal is to dynamically change a css keyframe
– Carlos Rocha