Class: UndoRedo

ol.interaction. UndoRedo

Undo/redo interaction


new UndoRedo(options)

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
maxLength number <optional>

max undo stack length (0=Infinity), default Infinity

layers Array.<ol.Layer>

array of layers to undo/redo

Fires:
  • event:undo
  • event:redo
  • change:add
  • change:remove
  • change:clear

Extends

  • ol.interaction.Interaction

Methods


_onAddRemove()

A feature is added / removed


blockEnd()

End an undo block


blockStart( [name])

Start an undo block

Parameters:
Name Type Argument Description
name string <optional>

name f the action


clear()

Clear undo stack


define(action, undoFn, redoFn)

Add a custom undo/redo

Parameters:
Name Type Description
action string

the action key name

undoFn function

function called when undoing

redoFn function

function called when redoing


getStack( [type])

Get first level undo / redo first level stack

Parameters:
Name Type Argument Description
type string <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
type string <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
action string

the action key name

prop any

an object that will be passed in the undo/redo functions of the action

name string

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
active boolean

setMap(map)

Remove the interaction from its current map, if any, and attach it to a new map, if any. Pass null to just remove the interaction from the current map.

Parameters:
Name Type Description
map ol.Map

Map.


setMaxLength(length)

Set undo stack max length

Parameters:
Name Type Description
length number

setMaxSize(size)

Set undo stack max size

Parameters:
Name Type Description
size number

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
type string <optional>

get redo stack length, default get undo

Returns:
Type
number

undo()

Undo last operation