AliasIO / Raphael.FreeTransform

Free transform tool for Raphaël elements.
http://elbertf.com
362 stars 107 forks source link

Raphael-free-transform looses a scale value #112

Closed Qvatra closed 10 years ago

Qvatra commented 10 years ago

in the following code re-scaling of the square object goes wrong: after clicking the button (which apply y-scale factor and make a rectangle out of our square) object displays correct BUT if you touch handles after that the previous scale values erase and the square displays again.

I want to be able to make rectangle in a code and re-scale it uniformly using handles afterwards. How to solve this problem?

<button id="btn" onclick="onClick()">apply scale</button>
<script>
    var r = Raphael(100, 0 , 300, 400);
    var square = r.rect(100,150, 100, 100).attr({ fill: "#aaa", stroke: "black", opacity: 0.5 });

    var ft = r.freeTransform(square, {}, function () {});
    ft.setOpts({
        attrs: { fill: 'white', stroke: '#000' },
        drag: false,
        keepRatio: ['axisX', 'axisY'],
        size: 5,
        scale: ['axisX', 'axisY'],
        rotate:false
    });

    function onClick() {
        ft.attrs.scale.y = 2;
        ft.apply();
    }
</script>
AliasIO commented 10 years ago

http://stackoverflow.com/questions/21288434/raphael-free-transform-looses-scale-value

Looks like this one has been answered on SO.