mercredi 15 juin 2016

Wrapping Text to more lines using JavaScript


Here I am trying to wrap the selected value from the drop down by comparing length of the string. The code i am using applying for the first line. How can i apply the same logic by comparing the length of the string for second line to next line.Below is some example i am using , what if my Item.value.length = 81.

var selectedItemLength = 
    Math.round(((Item.bounds.width) / (state.style.fontSize * (0.512 * scale))) * (pfConstants.LINE_HEIGHT));
//Here selectedItemLength gives 32
if (selectedItemLength < Item.value.length) {
  Item.value = 
    Item.value.substring(0, selectedItemLength) 
      + "n" 
      + Item.value.substring(selectedItemLength, Item.value.length);
}

Aucun commentaire:

Enregistrer un commentaire