forked from danny-toi/Snap.svg.FreeTransform
-
Notifications
You must be signed in to change notification settings - Fork 10
/
testload.html
51 lines (40 loc) · 1.2 KB
/
testload.html
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
<html>
<head>
<title>Free transform tool for Snap.svg elements</title>
<style type="text/css">
#main-container {
position: fixed;
background-color: #ddd;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<svg id="main-container"></svg>
<script src="snap.svg-min.js"></script>
<script src="snap.svg.free_transform.js"></script>
<script type="text/javascript">
var s = Snap('#main-container');
Snap.load( "test.svg", function( frag ) {
var g = s.g();
g.append(frag);
var allG = s.selectAll('.myG');
allG.forEach( function( el ) {
var ft = s.freeTransform( el, { snap: { rotate: 1 }, size: 8, draw: 'bbox' });
el.dblclick( function() {
if( el.data('ftStatus' ) ) {
ft.hideHandles();
el.data('ftStatus',0);
} else {
ft.showHandles();
el.data('ftStatus',1);
}
});
} );
} );
</script>
</body>
</html>