1

i'm using a wordpress theme who's using AcensorJS with wordpress. But here is the case, I want that the plugin can create each floor "dynamicaly". I'd like that if we had a new "article", this will be immediately add in the map.

Here my code :

var numbersOfArticle = $('section#wrapper > article').length;

  var rowStep = '[';
  var floorName = '[';

  for(var i=0; i<numbersOfArticle; i++) {

    rowStep += '['+i+', 1], '; // Create the Map
    floorName += '\'floor'+(i+1)+' \', '; // Create the name floor

  }

  rowStep = rowStep.substring(0, rowStep.length - 2); // To remove the "," for the last child
  floorName = floorName.substring(0, floorName.length - 2); // Same idea

  rowStep += ']';
  floorName += ']';

  $('#wrapper').ascensor({
    ascensorName: 'ascensor',
    childType: 'article',
    ascensorFloorName: floorName, // Here we set floor's name
    time: 1000,
    windowsOn: 0,
    direction: "chocolate",
    ascensorMap: rowStep, // Here we set the map
    easing: 'easeInOutQuad',
    keyNavigation: true,
    queued: false,
    queuedDirection: "y",
    overflow:"hidden"
  });

At the end we need for floorName = ['floor1', 'floor2', 'floor3'] and for rowStep = [[0,1], [1,1], [2,1]]. It's what I get with my for, so that's okay, but I don't know how can I interpret these two variables...

PS : I used PHP to create this, but now I need that Javascript does the job.

H4mm3R
  • 245
  • 4
  • 15

1 Answers1

0

I found by myself, so I give the answer, maybe someone else need it.

$('#wrapper').ascensor({
    ascensorName: 'ascensor',
    childType: 'article',
    ascensorFloorName: eval(floorName), // Here we set floor's name
    time: 1000,
    windowsOn: 0,
    direction: "chocolate",
    ascensorMap: eval(rowStep), // Here we set the map
    easing: 'easeInOutQuad',
    keyNavigation: true,
    queued: false,
    queuedDirection: "y",
    overflow:"hidden"
});

You have just to add "eval()", to "interpret" the variable.

Good day !

H4mm3R
  • 245
  • 4
  • 15