new UndoRedo(options)
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Fires:
- event:undo
- event:redo
- stack:add
- stack:remove
- stack:clear
Extends
- ol.interaction.Interaction
Methods
-
_onAddRemove()
-
A feature is added / removed
-
abort()
-
Abort last operation (remove from stack but no redo)
-
blockEnd()
-
End an undo block
-
blockStart( [name])
-
Start an undo block
Parameters:
Name Type Argument Description namestring <optional>
name f the action
-
clear()
-
Clear undo stack
-
define(action, undoFn, redoFn)
-
Add a custom undo/redo
Parameters:
Name Type Description actionstring the action key name
undoFnfunction function called when undoing
redoFnfunction function called when redoing
-
getStack( [type])
-
Get first level undo / redo first level stack
Parameters:
Name Type Argument Description typestring <optional>
get redo stack, default get undo
Returns:
- Type
- Array.<*>
-
hasRedo()
-
Check if redo is avaliable
Returns:
the number of redo
- Type
- number
-
hasUndo()
-
Check if undo is avaliable
Returns:
the number of undo
- Type
- number
-
length( [type])
-
Get first level undo / redo length
Parameters:
Name Type Argument Description typestring <optional>
get redo stack length, default get undo
Returns:
- Type
- number
-
push(action, prop, name)
-
Add a new custom undo/redo
Parameters:
Name Type Description actionstring the action key name
propany an object that will be passed in the undo/redo functions of the action
namestring action name
Returns:
true if the action is defined
- Type
- boolean
-
redo()
-
Redo last operation
-
setActive(active)
-
Activate or deactivate the interaction, ie. records or not events on the map.
Parameters:
Name Type Description activeboolean -
setMap(map)
-
Remove the interaction from its current map, if any, and attach it to a new map, if any. Pass
nullto just remove the interaction from the current map.Parameters:
Name Type Description mapol.Map Map.
-
setMaxLength(length)
-
Set undo stack max length
Parameters:
Name Type Description lengthnumber -
setMaxSize(size)
-
Set undo stack max size
Parameters:
Name Type Description sizenumber -
shift()
-
Remove undo action from the beginning of the stack. The action is not returned.
-
size( [type])
-
Get undo / redo size (includes all block levels)
Parameters:
Name Type Argument Description typestring <optional>
get redo stack length, default get undo
Returns:
- Type
- number
-
undo()
-
Undo last operation