mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 19:31:41 +00:00
20 lines
474 B
JavaScript
20 lines
474 B
JavaScript
// A controller holds a single action at a time and calls `.enter` and `.exit`
|
|
// to bind and unbind actions.
|
|
iD.Controller = function(map) {
|
|
var controller = { action: null };
|
|
|
|
controller.go = function(x) {
|
|
x.controller = controller;
|
|
x.map = map;
|
|
if (controller.action) {
|
|
controller.action.exit();
|
|
}
|
|
x.enter();
|
|
controller.action = x;
|
|
};
|
|
|
|
controller.go(iD.actions.Move);
|
|
|
|
return controller;
|
|
};
|