Skip to content

Commit

Permalink
fixed ImageProps.sizing (Issue #1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitbrent committed Feb 20, 2022
1 parent 9914d45 commit 5298627
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/core-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { CHART_NAME, PLACEHOLDER_TYPE, SHAPE_NAME, SLIDE_OBJECT_TYPES, TEXT_HALI

/**
* Coordinate number - either:
* - Inches
* - Percentage
* - Inches (0-n)
* - Percentage (0-100)
*
* @example 10.25 // coordinate in inches
* @example '75%' // coordinate as percentage of slide size
*/
export type Coord = number | string
export type Coord = number | `${number}%`
export type PositionProps = {
/**
* Horizontal position
Expand Down Expand Up @@ -466,23 +466,23 @@ export interface ImageProps extends PositionProps, DataOrPathProps {
/**
* Image width
*/
w: number
w: Coord
/**
* Image height
*/
h: number
h: Coord
/**
* Area horizontal position related to the image
* - Values: 0-n
* - `crop` only
*/
x?: number
x?: Coord
/**
* Area vertical position related to the image
* - Values: 0-n
* - `crop` only
*/
y?: number
y?: Coord
}
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/gen-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { EMU, REGEX_HEX_COLOR, DEF_FONT_COLOR, ONEPT, SchemeColor, SCHEME_COLORS } from './core-enums'
import { IChartOpts, PresLayout, TextGlowProps, PresSlide, ShapeFillProps, Color, ShapeLineProps } from './core-interfaces'
import { IChartOpts, PresLayout, TextGlowProps, PresSlide, ShapeFillProps, Color, ShapeLineProps, Coord } from './core-interfaces'

/**
* Translates any type of `x`/`y`/`w`/`h` prop to EMU
Expand All @@ -16,7 +16,7 @@ import { IChartOpts, PresLayout, TextGlowProps, PresSlide, ShapeFillProps, Color
* @param {PresLayout} layout - presentation layout
* @returns {number} calculated size
*/
export function getSmartParseNumber(size: number | string, xyDir: 'X' | 'Y', layout: PresLayout): number {
export function getSmartParseNumber(size: Coord, xyDir: 'X' | 'Y', layout: PresLayout): number {
// FIRST: Convert string numeric value if reqd
if (typeof size === 'string' && !isNaN(Number(size))) size = Number(size)

Expand Down
2 changes: 1 addition & 1 deletion src/pptxgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import * as genMedia from './gen-media'
import * as genTable from './gen-tables'
import * as genXml from './gen-xml'

const VERSION = '3.10.0-beta-20220219-1356'
const VERSION = '3.10.0-beta-20220220-1232'

export default class PptxGenJS implements IPresentationProps {
// Property getters/setters
Expand Down
14 changes: 7 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,13 +829,13 @@ declare namespace PptxGenJS {

/**
* Coordinate number - either:
* - Inches
* - Percentage
* - Inches (0-n)
* - Percentage (0-100)
*
* @example 10.25 // coordinate in inches
* @example '75%' // coordinate as percentage of slide size
*/
export type Coord = number | string
export type Coord = number | `${number}%`
export type PositionProps = {
/**
* Horizontal position
Expand Down Expand Up @@ -1285,23 +1285,23 @@ declare namespace PptxGenJS {
/**
* Image width
*/
w: number
w: Coord
/**
* Image height
*/
h: number
h: Coord
/**
* Area horizontal position related to the image
* - Values: 0-n
* - `crop` only
*/
x?: number
x?: Coord
/**
* Area vertical position related to the image
* - Values: 0-n
* - `crop` only
*/
y?: number
y?: Coord
}
}
/**
Expand Down

0 comments on commit 5298627

Please sign in to comment.