Skip to content

Commit

Permalink
latest fixes from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrierley committed Mar 15, 2017
1 parent 6c72f3f commit 8d66d46
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
8 changes: 8 additions & 0 deletions multiple.html
Expand Up @@ -18,6 +18,14 @@
<script src="snap.svg-min.js"></script>
<script src="snap.svg.free_transform.js"></script>

<style>
# .ftdisc { fill: grey; }
# .fthandle { fill: grey; }
# .ftcentercircle { fill: red; }
# .ftbbox { stroke-width: 10; }
# .ftaxisline { stroke-width: 10; }
</style>

<script type="text/javascript">
var s = Snap('#main-container');

Expand Down
35 changes: 28 additions & 7 deletions snap.svg.free_transform.js
Expand Up @@ -134,11 +134,17 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
fill: '#fff',
stroke: '#1e609d'
},
axisLineClass: 'ftaxisline',
bboxClass: 'ftbbox',
centerDiscClass: 'ftcenterdisc',
centerCircleClass: 'ftcentercircle',
distance: 1.2,
discDistance: 45,
discClass: 'ftdisc',
drag: true,
draw: ['bbox'],
keepRatio: false,
handleClass: 'fthandle',
range: {
rotate: [-180, 180],
scale: [-99999, 99999]
Expand Down Expand Up @@ -288,12 +294,14 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
stroke: ft.opts.attrs.stroke,
'stroke-dasharray': '4,3',
opacity: .5
});
})
.addClass( ft.opts.axisLineClass );

ft.handles[axis].disc = ft.group
.circle(ft.attrs.center.x, ft.attrs.center.y, ft.opts.size.axes)
.attr(ft.opts.attrs)
.attr('cursor', 'crosshair');
.attr('cursor', 'crosshair')
.addClass( ft.opts.discClass ) ;

// If the rotation is disabled, hide the handle.
if (!ft.opts.rotate.length) {
Expand All @@ -309,7 +317,8 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
'stroke-dasharray': '4,3',
fill: 'none',
opacity: .5
});
})
.addClass( ft.opts.bboxClass );

ft.handles.bbox = [];

Expand All @@ -330,7 +339,8 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
handle.element = ft.group
.rect(ft.attrs.center.x, ft.attrs.center.y, ft.opts.size[handle.isCorner ? 'bboxCorners' : 'bboxSides'] * 2, ft.opts.size[handle.isCorner ? 'bboxCorners' : 'bboxSides'] * 2)
.attr(ft.opts.attrs)
.attr('cursor', cursor);
.attr('cursor', cursor)
.addClass( ft.opts.handleClass);

ft.handles.bbox[i] = handle;
}
Expand All @@ -343,15 +353,17 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
stroke: ft.opts.attrs.stroke,
'stroke-dasharray': '4,3',
opacity: .3
});
})
.addClass( ft.opts.centerCircleClass );
}

if (ft.opts.drag.indexOf('center') !== -1) {
ft.handles.center = {};

ft.handles.center.disc = ft.group
.circle(ft.attrs.center.x, ft.attrs.center.y, ft.opts.size.center)
.attr(ft.opts.attrs);
.attr(ft.opts.attrs)
.addClass( ft.opts.centerDiscClass );
}

// Drag x, y handles.
Expand Down Expand Up @@ -651,6 +663,11 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
ft.circle = null;
}

if (ft.group) {
ft.group.remove();
ft.group = null;
}

return ft;
};

Expand Down Expand Up @@ -745,6 +762,10 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
if (ft.opts.rotate.indexOf('axisX') >= 0 || ft.opts.scale.indexOf('axisX') >= 0) {
ft.axes.push('x');
}
if (ft.opts.rotate.indexOf('axisY') >= 0 || ft.opts.scale.indexOf('axisY') >= 0) {
ft.axes.push('y');
}


['drag', 'rotate', 'scale'].map(function (option) {
if (!ft.opts.snapDist[option]) {
Expand Down Expand Up @@ -833,7 +854,7 @@ Snap.plugin(function(Snap, Element, Paper, global, Fragment) {
*/
ft.unplug = function() {
var attrs = ft.attrs;

console.log('unplug');
ft.hideHandles();

delete subject.freeTransform;
Expand Down

0 comments on commit 8d66d46

Please sign in to comment.