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
- Source:
Fires:
clearMaxDimensions()
#
Clear the maximum dimensions
- Source:
Fires:
clearMinDimensions()
#
Clear the minimum dimensions
- Source:
Fires:
clearOriginalDimensions()
#
Reset and remove the default dimensions
- Source:
Fires:
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 |
- Source:
Returns:
Dimensions object with width & height
- Type
- Object
getCurrentDimensions() → {Object}
#
getCurrentScale() → {number|null
}
#
null
}
#
Get the current scale of the object
- Source:
Returns:
A scale (1=100%), or null if not applicable
- Type
-
number
|
null
getDefaultDimensions() → {Object}
#
getMaxDimensions() → {Object}
#
getMinDimensions() → {Object}
#
getOriginalDimensions() → {Object}
#
getRatio() → {number}
#
Get the fixed aspect ratio (width/height)
- Source:
Returns:
Aspect ratio
- Type
- number
isCurrentDimensionsValid() → {boolean}
#
Checks whether the current dimensions are numeric and within range
- Source:
Returns:
Current dimensions are valid
- Type
- boolean
isDefault() → {boolean}
#
Get the default state of the scalable object
- Source:
Returns:
Default size or custom
- Type
- boolean
isEnforcedMax() → {boolean}
#
The object enforces the maximum dimensions when scaling
- Source:
Returns:
Enforces the maximum dimensions
- Type
- boolean
isEnforcedMin() → {boolean}
#
The object enforces the minimum dimensions when scaling
- Source:
Returns:
Enforces the minimum dimensions
- Type
- boolean
isFixedRatio() → {boolean}
#
Check if the object has a fixed ratio
- Source:
Returns:
The object has a fixed ratio
- Type
- boolean
isTooLarge() → {boolean}
#
Check if current dimensions are greater than maximum dimensions in either direction
Only possible if enforceMax is false.
- Source:
Returns:
Current dimensions are greater than maximum dimensions
- Type
- boolean
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.
- Source:
Returns:
Current dimensions are greater than maximum dimensions
- Type
- boolean
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 |
- Source:
Fires:
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 |
- Source:
Fires:
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 |
- Source:
Fires:
setMinDimensions(dimensions)
#
Set the minimum dimensions
Parameters:
Name | Type | Description |
---|---|---|
dimensions |
Object | Dimensions object with width & height |
- Source:
Fires:
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 |
- Source:
Fires:
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 |
- Source:
Fires:
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 |
- Source:
Returns:
Dimensions object with width and height
- Type
- Object
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 |
- Source:
Returns:
Valid or invalid dimensions object
- Type
- boolean
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: