do concatenation in $ .keyframe.define parameters

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 follows:

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

As I have done, it is giving error. What is the correct way to do concatenation in parameters of $.keyframe.define ?

I've also tried this, but it gives an error on the right side of the colon:

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

I even managed it as follows:

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

But when I add the variable tMin and tMax on the left side of the error:

 tMin + "%" : { "margin-left":-tempoImagens + "%"},
 tMax + "%" : { "margin-left":-tempoImagens + "%"},
    
asked by anonymous 26.10.2017 / 11:40

1 answer

1
Assuming you have the values of tMin and tMax defined, and want to concatenate, you 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 it's really just building a javascript array.

[{
  name: 'tocaSlide',
  tMinConcat: {tMinAttr},
  tMaxConcat: {tMaxAttr}
}]
    
26.10.2017 / 15:08