Angular Directive ( ng-areas ) that let you select and manipulate multiple areas on an image, create, edit, move and resize them too.
$ bower install angular-areas
<div ng-controller="DemoController">
<img ng-areas="areasArray" ng-areas-width="900"
ng-areas-allow="{'edit':true, 'move':true, 'resize':true, 'select':true, 'remove':true, 'nudge':false}"
ng-areas-on-add="onAddArea"
ng-areas-on-remove="onRemoveArea"
ng-areas-on-change="onChangeAreas900"
ng-areas-extend-data="{pageNumber: 1, tag: 'img900px'}"
ng-src="https://github.com/delkant/angular-areas/raw/master/aImage.jpg">
</div>
Check out the DEMO
This plugin is fully compatible with every modern browser and IE >= 9.
An area is described (when retrieved or set) by a json object:
{
x, // X coordinate (Position)
y, // Y coordinate (Position)
z, // Z-index (0 when inactive or 100 when focused)
width, // Width of the area (Size)
height // Height of the area (Size)
}
Here is a list of available options for selectAreas, with their default value:
ng-areas : Required attribute. Area list areas ([]) : list of areas to add to the image from the beginning (id will be ignored);
controller i.e.:
$scope.areasArray = [ {
"x" : 557,
"y" : 35,
"z" : 100,
"height" : 130,
"width" : 925,
"name" : "Menu Options",
"cssClass" : "class_red",
"id" : 37,
"description" : "Menu"
}, {
"x" : 822,
"y" : 274,
"z" : 0,
"height" : 250,
"width" : 829,
"name" : "AngularJS Main Logo",
"cssClass" : "class_red",
"id" : 35,
"description" : "AngularJS Main Logo"
} ];
template i.e.:
<img ng-areas="areasArray" src="https://github.com/delkant/angular-areas/raw/master/aImage.jpg">
ng-areas-width (0) : When not 0, scale the image to this width (px).
ng-areas-extend-data each area will have the properties defined on this JSON object. This can be used when you have multiple images with areas on them and you want to know to what image belongs a area-box. You could also use this to create tags to identify the fields.
ng-areas-allow : Json Object
i.e. ng-areas-allow="{'edit':true, 'move':true, 'resize':false, 'select':true, 'remove':false, 'nudge':false}"
Three events are fired by the plugin:
So far one event is listening by the plugin:
on "ngAreas:renameByAreaId"
usage
$scope.$broadcast("ngAreas:renameByAreaId", {
areaid : areaid,
name : "a new Label or Name for this box"
});
MIT
Inspired by https://github.com/360Learning/jquery-select-areas