calculateYPosition (layers, layer) {
    // Get the layer's currently configured Y position
    let attachYLayerPosition = this.getLayerValue(layers, layer, 'y');

    // If this is an object and has the attach property
    if (typeof attachYLayerPosition === 'object' && attachYLayerPosition.attach !== 'undefined') {
      // Get the layer to attach to
      let attachYLayer = layers[layer.y.attach];

      // Calculate the Y offset
      let attachYLayerHeight = 0;
      switch (attachYLayer.type) {
        case 'text':
          let attachYLayerText = attachYLayer.text.split('\n');
          if (attachYLayer.text !== '') {
            attachYLayerHeight = (attachYLayerText.length * (this.getLayerValue(layers, attachYLayer, 'lineHeight') || this.getLayerValue(layers, attachYLayer, 'fontSize')));
          }
          break;
        default:
          if (typeof this.getLayerValue(layers, attachYLayer, 'height') !== 'undefined') {
            attachYLayerHeight = this.getLayerValue(layers, attachYLayer, 'height');
          }
          break;
      }

      // Add any additionally configured offset value
      let attachYLayerOffset = (layer.y.offset || 0);

      // Add them together and recursively call this function if the next layer has an attachment
      attachYLayerPosition = attachYLayerHeight + this.calculateYPosition(layers, attachYLayer) + attachYLayerOffset;
    }

    // Return the value
    return attachYLayerPosition;
  }
/**
   * Calculates the Y position of an element based on any attachments etc.
   *
   * @param {object} layers - The object of all layers
   * @param {object} layer - The layer to calculate the Y position for
   *
   * @return {integer} The Y position
   */
Calculates the Y position of an element based on any attachments etc.
@param {object} layers - The object of all layers
@param {object} layer - The layer to calculate the Y position for

@return {integer} The Y position
Calculates the Y position of an element based on any attachments etc . @param { object } layers - The object of all layers @param { object } layer - The layer to calculate the Y position for @return { integer } The Y position
calculateYPosition (layers, layer) {
    let attachYLayerPosition = this.getLayerValue(layers, layer, 'y');
    if (typeof attachYLayerPosition === 'object' && attachYLayerPosition.attach !== 'undefined') {
      let attachYLayer = layers[layer.y.attach];
      let attachYLayerHeight = 0;
      switch (attachYLayer.type) {
        case 'text':
          let attachYLayerText = attachYLayer.text.split('\n');
          if (attachYLayer.text !== '') {
            attachYLayerHeight = (attachYLayerText.length * (this.getLayerValue(layers, attachYLayer, 'lineHeight') || this.getLayerValue(layers, attachYLayer, 'fontSize')));
          }
          break;
        default:
          if (typeof this.getLayerValue(layers, attachYLayer, 'height') !== 'undefined') {
            attachYLayerHeight = this.getLayerValue(layers, attachYLayer, 'height');
          }
          break;
      }
      let attachYLayerOffset = (layer.y.offset || 0);
      attachYLayerPosition = attachYLayerHeight + this.calculateYPosition(layers, attachYLayer) + attachYLayerOffset;
    }
    return attachYLayerPosition;
  }
calculateYPosition ( layers , layer ) { let attachYLayerPosition = this . getLayerValue ( layers , layer , 'y' ) ; if ( typeof attachYLayerPosition === 'object' && attachYLayerPosition . attach !== 'undefined' ) { let attachYLayer = layers [ layer . y . attach ] ; let attachYLayerHeight = 0 ; switch ( attachYLayer . type ) { case 'text' : let attachYLayerText = attachYLayer . text . split ( '\n' ) ; if ( attachYLayer . text !== '' ) { attachYLayerHeight = ( attachYLayerText . length * ( this . getLayerValue ( layers , attachYLayer , 'lineHeight' ) || this . getLayerValue ( layers , attachYLayer , 'fontSize' ) ) ) ; } break ; default : if ( typeof this . getLayerValue ( layers , attachYLayer , 'height' ) !== 'undefined' ) { attachYLayerHeight = this . getLayerValue ( layers , attachYLayer , 'height' ) ; } break ; } let attachYLayerOffset = ( layer . y . offset || 0 ) ; attachYLayerPosition = attachYLayerHeight + this . calculateYPosition ( layers , attachYLayer ) + attachYLayerOffset ; } return attachYLayerPosition ; }
Calculates the Y position of an element based on any attachments etc.
Calculates the Y position of an element based on any attachments etc .
// Get the layer's currently configured Y position // If this is an object and has the attach property // Get the layer to attach to // Calculate the Y offset // Add any additionally configured offset value // Add them together and recursively call this function if the next layer has an attachment // Return the value