Constructor
new ve.dm.Scalable([config])
#
Scalable object.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Mixes in:
- Source:
Methods
clearDefaultDimensions()
#
Reset and remove the default dimensions
Fires:
- Source:
clearMaxDimensions()
#
Clear the maximum dimensions
Fires:
- Source:
clearMinDimensions()
#
Clear the minimum dimensions
Fires:
- Source:
clearOriginalDimensions()
#
Reset and remove the default dimensions
Fires:
- Source:
clone() → {ve.dm.Scalable}
#
getBoundedDimensions(dimensions, [grid]) → {Object}
#
Get a set of dimensions bounded by current restrictions, from specified dimensions
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
dimensions |
Object | Dimensions object with width & height |
|
grid |
number |
optional |
Optional grid size to snap to |
Returns:
Dimensions object with width & height
- Type
- Object
- Source:
getCurrentDimensions() → {Object}
#
getCurrentScale() → {number|null}
#
null}
#
Get the current scale of the object
Returns:
A scale (1=100%), or null if not applicable
- Type
-
number
|
null
- Source:
getDefaultDimensions() → {Object}
#
getMaxDimensions() → {Object}
#
getMinDimensions() → {Object}
#
getOriginalDimensions() → {Object}
#
getRatio() → {number}
#
Get the fixed aspect ratio (width/height)
Returns:
Aspect ratio
- Type
- number
- Source:
isCurrentDimensionsValid() → {boolean}
#
Checks whether the current dimensions are numeric and within range
Returns:
Current dimensions are valid
- Type
- boolean
- Source:
isDefault() → {boolean}
#
Get the default state of the scalable object
Returns:
Default size or custom
- Type
- boolean
- Source:
isEnforcedMax() → {boolean}
#
The object enforces the maximum dimensions when scaling
Returns:
Enforces the maximum dimensions
- Type
- boolean
- Source:
isEnforcedMin() → {boolean}
#
The object enforces the minimum dimensions when scaling
Returns:
Enforces the minimum dimensions
- Type
- boolean
- Source:
isFixedRatio() → {boolean}
#
Check if the object has a fixed ratio
Returns:
The object has a fixed ratio
- Type
- boolean
- Source:
isTooLarge() → {boolean}
#
Check if current dimensions are greater than maximum dimensions in either direction
Only possible if enforceMax is false.
Returns:
Current dimensions are greater than maximum dimensions
- Type
- boolean
- Source:
Check if current dimensions are greater than maximum dimensions in either direction
Only possible if enforceMax is false.
isTooSmall() → {boolean}
#
Check if current dimensions are smaller than minimum dimensions in either direction
Only possible if enforceMin is false.
Returns:
Current dimensions are greater than maximum dimensions
- Type
- boolean
- Source:
Check if current dimensions are smaller than minimum dimensions in either direction
Only possible if enforceMin is false.
setCurrentDimensions(dimensions)
#
Set the current dimensions
Also sets the aspect ratio if not set and in fixed ratio mode.
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
Fires:
- Source:
Set the current dimensions
Also sets the aspect ratio if not set and in fixed ratio mode.
setDefaultDimensions(dimensions)
#
Set the default dimensions
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
Fires:
- Source:
setEnforcedMax(enforceMax)
#
Set enforcement of maximum dimensions
Parameters:
| Name | Type | Description |
|---|---|---|
enforceMax |
boolean | Enforces the maximum dimensions |
- Source:
setEnforcedMin(enforceMin)
#
Set enforcement of minimum dimensions
Parameters:
| Name | Type | Description |
|---|---|---|
enforceMin |
boolean | Enforces the minimum dimensions |
- Source:
setMaxDimensions(dimensions)
#
Set the maximum dimensions
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
Fires:
- Source:
setMinDimensions(dimensions)
#
Set the minimum dimensions
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
Fires:
- Source:
setOriginalDimensions(dimensions)
#
Set the original dimensions
Also resets the aspect ratio if in fixed ratio mode.
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
Fires:
- Source:
Set the original dimensions
Also resets the aspect ratio if in fixed ratio mode.
setRatioFromDimensions(dimensions)
#
Set the fixed aspect ratio from specified dimensions.
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | Dimensions object with width & height |
- Source:
toggleDefault([isDefault])
#
Toggle the default size setting, or set it to particular value
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
isDefault |
boolean |
optional |
Default or not, toggles if unset |
Fires:
- Source:
getDimensionsFromValue(dimensions, [ratio]) → {Object}static
#
Calculate the dimensions from a given value of either width or height. This method doesn't take into account any restrictions of minimum or maximum, it simply calculates the new dimensions according to the aspect ratio in case it exists.
If aspect ratio does not exist, or if the original object is empty, or if the original object is fully specified, the object is returned as-is without calculations.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dimensions |
Object | Dimensions object with either width or height if both are given, the object will be returned as-is. Properties:
|
|||||||||||||
ratio |
number |
optional |
The image width/height ratio, if it exists |
Returns:
Dimensions object with width and height
- Type
- Object
- Source:
isDimensionsObjectValid(dimensions) → {boolean}static
#
Check if an object is a dimensions object. Make sure that if width or height are set, they are not 'undefined'.
Parameters:
| Name | Type | Description |
|---|---|---|
dimensions |
Object | A dimensions object to test |
Returns:
Valid or invalid dimensions object
- Type
- boolean
- Source:
Events
currentSizeChange(currentDimensions)
#
Current changed
Parameters:
| Name | Type | Description |
|---|---|---|
currentDimensions |
Object | Current dimensions width and height |
- Source:
defaultSizeChange(isDefault)
#
Default size or state changed
Parameters:
| Name | Type | Description |
|---|---|---|
isDefault |
boolean | The size is default |
- Source:
maxSizeChange(maxDimensions)
#
Max size changed
Parameters:
| Name | Type | Description |
|---|---|---|
maxDimensions |
Object | Max dimensions width and height |
- Source:
minSizeChange(minDimensions)
#
Min size changed
Parameters:
| Name | Type | Description |
|---|---|---|
minDimensions |
Object | Min dimensions width and height |
- Source: