Word Wrapping

This demonstration displays very long text, which would normally stay on a single line. However, the text width property forces an absolute width, which makes the text wrap on word boundaries.

Configuration

To have the text based in the top-left, and wrap down, the anchor is set to [-50,-50]. A very thin border is added as 0.1 which usually renders as a single pixel.

Animation

The width is animated back and forth over 4 seconds per leg.

Center Alignment

The second animation, which can be seen by clicking the button labeled 2 underneath the editor, is a simplified version that animates with center alignment.

story = {
  item: {
    text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    init: {
      border:0.1,
      padding:5,
      font:5,
      width:100,
      pos:[-50,-50],
      anchor:[-50,-50]
    },
    action: {
      anim:{ dur:4, rep:[1,'yoyo'] }, 
      width:60
    }
  }
};
story = {
  item: {
    text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    init: {
      border:0.1,
      padding:5,
      font:5,
      width:100,
      align: "center"
    },
    action: {
      anim:{ dur:4, rep:[1,'yoyo'] }, 
      width:60
    }
  }
};