0

I have a very simple view class.

MyView(subView) {
  this.node = subView;
}

MyView.render = function() {
  this.node.render();
}

Using this impl with e.g. a y-rotation around 0.5,0.5 works as expected, the surface is rotated correctly.

var modifier = new famous.modifiers.StateModifier({
  origin: [0.5, 0.5]
});

modifier.setTransform(famous.core.Transform.rotateY(Math.PI / 3 * 1), { duration: 10000, curve: 'easeInOut' });

context.add(modifier).add(new MyView( new Surface(...)))

To be able to use the parents size i subclassed the ContextualView and override the commit().

commit: function (context) {
  var transform = context.transform;
  var origin = context.origin;
  var size = context.size;
  var align = context.align;

  if (size) {
    // stolen from gridlayout
    transform = famous.core.Transform.moveThen([-size[0]*origin[0], -size[1]*origin[1], 0], transform);
  }

  return {
    origin : origin,
    transform: transform,
    align : align,
    size: size,
    target: [
      {
        target : this.node.render()
      }
    ]
  };
}, 

Unfortunaly this does not work, the rotation is different. What is the minimal code a commit() method must contain to have the same effect like render?

Jens Zastrow
  • 287
  • 1
  • 3
  • 9

1 Answers1

1

Solution: Removing the origin from returned render-tree, solves the issue.

commit: function (context) {
var transform = context.transform;
var origin = context.origin;
var size = context.size;
var align = context.align;

if (size) {
  // stolen from gridlayout
  transform = famous.core.Transform.moveThen([-size[0]*origin[0], -size[1]*origin[1], 0], transform);
}

return {
  transform: transform,
  align : align,
  size: size,
  target : this.node.render()
};

}

Jens Zastrow
  • 287
  • 1
  • 3
  • 9