How to set webkit-transform programatically with jQuery?

119 views Asked by At

I am trying to set the transform3d attribute with jQuery. To do it, I am using the following function;

  setZIndexes(element, value) {
    $('#' + element + '').css({
      "-webkit-transform": 'translate3d(0, ' + (-this.offsetHeight) + ',' + value + 'px)',
      "-ms-transform": 'translate3d(0, ' + (-this.offsetHeight) + ',' + value + 'px)',
      "transform": 'translate3d(0, ' + (-this.offsetHeight) + ',' + value + 'px)',
    });
  }

Then, I am printing the values with the following function to see if it is changed or not;

 getZIndexes(el) {
    var results = $(el).css('-webkit-transform').match(/matrix(?:(3d)\(\d+(?:, \d+)*(?:, (\d+))(?:, (\d+))(?:, (\d+)), \d+\)|\(\d+(?:, \d+)*(?:, (\d+))(?:, (\d+))\))/)

    if (!results) return [0, 0, 0];
    if (results[1] == '3d') return results.slice(2, 5);

    results.push(0);
    return results.slice(5, 8);
  }

However, it always returns to [0, 0, 0]

0

There are 0 answers