forked from component/selection-rect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (54 loc) · 1.04 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Module dependencies.
*/
var inherit = require('inherit');
var Rect = require('rect');
var css = require('css');
/**
* Expose `Selection`.
*/
module.exports = Selection;
/**
* Initialize a Selection rect.
*/
function Selection(top, left, width, height) {
this.el = document.createElement('div');
this.el.className = 'selection-rect';
Rect.apply(this, arguments);
}
/**
* Inherit from `Rect.prototype`.
*/
inherit(Selection, Rect);
/**
* Move proxy.
*/
Selection.prototype.moveTo = function(left, top){
Rect.prototype.moveTo.apply(this, arguments);
css(this.el, {
top: top,
left: left
});
};
/**
* Size proxy.
*/
Selection.prototype.size = function(width, height){
Rect.prototype.size.apply(this, arguments);
css(this.el, {
width: this.width,
height: this.height
});
};
/**
* To proxy.
*/
Selection.prototype.to = function(right, bottom){
Rect.prototype.to.apply(this, arguments);
css(this.el, {
left: this.left,
top: this.top,
width: this.width,
height: this.height
});
};