Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. //Panorama panel.position workaround - Requires Vectors.js! (https://github.com/Perryvw/Phase/blob/master/src/Vector.js)
  2. //Credits to Perry
  3. function SetPositionRotation( element, position, rotation ) {
  4. var oldPosition = element.data().oldPosition || new Vector();
  5. var oldRotation = element.data().oldRotation || 0;
  6.  
  7. //Revert previous transformation
  8. element.style.transform = "translate3d(" +
  9. -oldPosition.x + "px, " + -oldPosition.y + "px, 0px) rotateZ("+(-oldRotation)+"deg)";
  10.  
  11. //Apply new transformation
  12. element.style.transform = "rotateZ("+rotation+"deg) translate3d(" +
  13. position.x + "px, " + position.y + "px, 0px)";
  14.  
  15. element.data().oldPosition = position;
  16. element.data().oldRotation = rotation;
  17. }
  18.  
  19. //Example Usage:
  20. SetPositionRotation( $('#someID'), new Vector(100, 0, 0), 43 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement