anam
anam

Reputation: 3913

fabricjs change border size and colour on some event not working

I am using below code to change selected border and border color of Selected Shape, but once i call that event object goes to smaller size and doesn't re-size to large .

$('#shape_border_colour').spectrum({

        color : "#f00",
        change : function(color) {
            console.log(' color change' + color.toHexString());

            var obj = canvas.getActiveObject();
            shape_strokeColor=color.toHexString();
            if (!obj)
                return;

            obj.set('stroke', shape_strokeColor);
            obj.set('strokeWidth',shape_strokeWidth);

            //stroke : 'white',
            //strokeWidth : 5
            //obj.set('textBackgroundColor', color.toHexString());

            canvas.renderAll();

        }
    });

    $('#shape_border_size').change(function() {
        console.log(' size changed to ' + $(this).val());
        img_border = $(this).val();
        var obj = canvas.getActiveObject();
        shape_strokeWidth=$(this).val();
        if (!obj)
            return;

        obj.set('stroke',shape_strokeColor );
        obj.set('strokeWidth', shape_strokeWidth);
        canvas.renderAll();

    });

what would be the problem ??

Upvotes: 0

Views: 2814

Answers (1)

anam
anam

Reputation: 3913

I solved this issue by doing parseInt(shape_strokeWidth) , stroke width takes number value what i was doing wrong was passing string .

Upvotes: 1

Related Questions