AbimannanMuthusamy / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

changing stroke style of a connection changes stroke style for other connections (add setPaintStyle method to Connection object) #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use mouse hover and exit code from selectDemo.html example.

connection.oldStrokeStyle = connection.paintStyle.strokeStyle;
jsPlumb.extend(connection.paintStyle, {strokeStyle:'#EE5500'});
connection.repaint(); 

2. extended this idea to change the color of all connections for a source using 
jsPlumb.getConnections.

var c1 = jsPlumb.getConnections({scope:"DEFAULT", source:source});

    for(var i=0; i < c1.DEFAULT.length; i++){
        var con = c1.DEFAULT[i];

        con.connection.oldStrokeStyle = con.connection.paintStyle.strokeStyle;
        alert(con.connection.hasOwnProperty("paintStyle"));
        jsPlumb.extend(con.connection.paintStyle, {
            strokeStyle : 'rgba(204,102,0,0.7)'
        });
        con.connection.repaint();

    }

3. In the for loop for the second connection onwards strokeStyle changes to 
'rgba(204,102,0,0.7)'. This can be found in below statement in firbug debugging.

con.connection.oldStrokeStyle = con.connection.paintStyle.strokeStyle;

What version of the product are you using? On what browser and OS?
Version: 1.2.6 RC1

Please provide any additional information below.

Original issue reported on code.google.com by rkkil...@gmail.com on 16 Mar 2011 at 4:39

GoogleCodeExporter commented 9 years ago
without a demo page it's difficult for me to see what's happening here, but it 
would appear that you're passing the same JS object in as the paint style for 
all your connections; then when you make a change to it, everything is 
affected.  i'm not sure that this is a bug, but then i can't be, without a demo 
page.  

the selectDemo page is a work in progress and i would not want to release a 
version of jsPlumb with such an awful API to achieve something simple like 
changing a connection's style - i think perhaps what this shows is that 
Connections should have a setStyle method, like the one i just added to 
Endpoint. 

Original comment by simon.po...@gmail.com on 16 Mar 2011 at 9:26

GoogleCodeExporter commented 9 years ago
i've now added a setPaintStyle method to Connection in 1.2.6-RC1. i haven't 
finished the documentation yet but you can see it in use in 
demo/jquery/selectDemo.html.  marking this as fixed.

Original comment by simon.po...@gmail.com on 19 Mar 2011 at 11:08