concatenate into $.keyframe.define parameters

Asked

Viewed 26 times

0

I have the following function:

      $.keyframe.define([{
          name: 'tocaSlide',
          tMin : {'margin-left': tempoImagens},
          tMax : {'margin-left': tempoImagens},
      }]);    

But I need to insert '%' after the variables, as below:

      $.keyframe.define([{
          name: 'tocaSlide',
          tMin'%' : { margin-left:-tempoImagens'%'},
          tMax'%' : { margin-left:-tempoImagens'%'}
      }]);    

The way I did, it’s a mistake. What is the correct way to concatenate into parameters of the $.keyframe.define?

I’ve tried that too, but it makes a mistake on the right side of the two points:

      $.keyframe.define([{
          name: 'tocaSlide',
          tMin + '%' + : { margin-left:-tempoImagens + '%' + },
          tMax + '%' + : { margin-left:-tempoImagens + '%' + }
      }]);    

I even got it the way down:

'%' : { "margin-left":-tempoImagens + "%"}, '%' : { "margin-left":-tempoImagens + "%"},

But when I add the variable Tmin and tmax on the left side of the error:

 tMin + "%" : { "margin-left":-tempoImagens + "%"},
 tMax + "%" : { "margin-left":-tempoImagens + "%"},
  • See if you can’t do it just like this: Tmin+'%' in javascrip/jQuery uses + to concatenate

  • that is the problem, already try so too but it does not work:

  • And so you tried: 'Tmin%': { 'margin-left:-timeImagens%'}, ? I took this example from Docs

  • I can’t because Tmin is a variable

  • Then Tmin comes from a certain value ? if that’s it you have to add % already where mounts the variable

  • No, Tmin and tmax receive different values with each iteration of a for loop;

  • Have you tried concatenating inside the loop ?

  • Aim, but how do I print the result of a text variable that contains all the string within the function $.keyframe.define([{ ???

  • Before entering $.keyframe makes an alias, var tMinConcat = Tmin+'%'; and inside of the function puts tMinConcat, I think you will get it so

  • It’s kind of confusing for me, you could post an answer with this solution doing favor?

  • It’s just that I’m not sure if it’s gonna work out, but I’m gonna answer right there

  • let’s try, hope is the last that dies

Show 7 more comments

1 answer

1


Assuming you have the values of tMin and tMax defined, and want to concatenate, must concatenate outside the array:

var tMinConcat = tMin + '%';
var tMaxConcat = tMax + '%';
var tMinAttr = 'margin-left:-tempoImagens' + '%';
var tMaxAttr = 'margin-left:-tempoImagens' + '%';
$.keyframe.define([{
  name: 'tocaSlide',
  tMinConcat: {tMinAttr},
  tMaxConcat: {tMaxAttr}
}]);

See that actually, it’s just building a javascript array.

[{
  name: 'tocaSlide',
  tMinConcat: {tMinAttr},
  tMaxConcat: {tMaxAttr}
}]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.