-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathannotateimageDirective.ts
44 lines (36 loc) · 1.39 KB
/
annotateimageDirective.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// <reference path="../reference.ts" />
interface AnnotateImageDirectiveScope extends ng.IScope {
image: UIAnnotateImage;
width: number;
height: number;
tool: string;
}
myApp.directives.directive('annotateimage', ['$isolator', function ($isolator: $isolatorService): ng.IDirective {
return {
restrict: 'E',
link: (scope: AnnotateImageDirectiveScope, element, attrs) => {
scope = $isolator.setupDirective(
{
image: '=',
width: '=',
height: '=',
tool:'=',
}, scope, element, attrs, annotateimage.html);
// Find the canvas
var canvas: HTMLCanvasElement = <HTMLCanvasElement>element.find('canvas')[0];
// Setup the manager only once
var manager = new AnnotationDisplayManager(canvas);
// Watch the image
scope.$watch('image', () => {
manager.setImageModel(scope.image);
});
// Watch the tool
scope.$watch('tool', () => {
manager.setTool(scope.tool);
});
// Watch the size
scope.$watch('width', () => { manager.resize(scope.width,scope.height) });
scope.$watch('height', () => { manager.resize(scope.width, scope.height) });
}
}
}]);