forked from trepmag/jrac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
117 lines (81 loc) · 3.2 KB
/
README.txt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
* SUMMARY *
jQuery Resize And Crop (jrac) is a jQuery plugin that build a viewport around a
given image permitting to visually resize an image and place a crop. Then it is
possible to use the coordinates data to be used for any purpose.
* DEMO *
http://www.lacordeaucou.net/z/jrac/example/
* FEATURES *
- Resize and move image
- Resize and move crop
- Resize viewport
- Aims to be integrated with any server side image processor
* INSTRUCTIONS *
The 'jrac' method implement the whole business which can take an optional
setting object argument:
$('img').jrac();
The default setting object is the following:
var settings = {
'crop_width': 200,
'crop_height': 100,
// The two following properties define the crop position (relative to the
// image).
'crop_x': 0,
'crop_y': 0,
'crop_resize': true,
'image_width': null,
'image_height': null,
'zoom_min': 100,
'zoom_max': 3000,
'viewport_resize': true,
// The two following properties allow to position the content (negative
// value allowed). It can be use to focus the viewport on the cropped
// part of the image.
'viewport_content_x': 0,
'viewport_content_y': 0,
// Submit here a callback function (context is the viewport), see below.
'viewport_onload': null
};
The 'viewport_onload' property can take an function callback which interface is:
function() // which the context is $viewport
The $viewport context is a div jQuery wrapped element that surround the target
image. This object get the following subsequent properties:
- $viewport.$container: a container holding the viewport and the zoom widget.
- $viewport.$image: the target image jQuery wrapped.
- $viewport.$crop: the crop object.
- $viewport.observator: an object which process all events of the viewport.
The main method of the $viewport.observator is 'register' which register an
element for an event:
$viewport.observator.register(String event_name, jQuery wrapped elements[, callback onevent_callback])
To unregister an event use:
$viewport.observator.unregister(string event_name)
The observator events are the following which you can then trigger some actions
on with the jQuery bind method or by giving a function to the onvevent_callback
argument:
crop_x
crop_y
crop_width
crop_height
image_width
image_height
Example:
$('img').rac({'viewport_onload', function() {
var $viewport = this;
$viewport.register('crop_x', $('input#cropx'), function(event_name, element, value) {
element.val(value);
}
}
There is also an event 'viewport_events' which is triggered on every events of
the previous decribed viewport observator. Use the jQuery bind methode to act on
it.
* REQUIEREMENTS *
jrac use jQuery and jQuery-UI.
- Developped with jQuery 1.6.1 and jQuery-UI 1.8.13
- Tested with jQuery 1.4.4 and jQuery-UI 1.8.7
* ACKNOWLEDGEMENT *
- The jrac/images/loading.gif image file come from http://www.ajaxload.info/.
- The picture used in the example is provided (perhaps) by courtesy of Loulou
from Sos-Chats Geneve.
- Syntax Highlighting in JavaScript (SHJS) used for the display of the code in
the example, http://shjs.sourceforge.net/.
* DOWNLOAD *
https://github.com/trepmag/jrac