Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to chain calls to removeLayer using v5.4 #19

Closed
BillyRayPreachersSon opened this issue Jun 9, 2012 · 1 comment
Closed

Not able to chain calls to removeLayer using v5.4 #19

BillyRayPreachersSon opened this issue Jun 9, 2012 · 1 comment

Comments

@BillyRayPreachersSon
Copy link

It seems that when using v5.4, you can'tt chain calls to removeLayer. Here's my test code from Issue #18:

var MyObj = {
    canvas: $('<canvas />'),

    addLayer: function() {
        this.canvas.addLayer(this.drawLines);
    },

    drawLines: function lines(ctx) {
        console.log('MyObj.drawLines is being called');
        console.log('"this" context = ', this);
    }
}

Here's what I see when using v5.3.1:

MyObj.canvas.addLayer({ method:'drawRect', name:'myBox', fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.addLayer({ method:'drawRect', name:'myBox2', fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.getLayers().length;                            // 2
MyObj.canvas.getLayer('myBox');                             // Object
MyObj.canvas.getLayer('myBox2');                            // Object
MyObj.canvas.removeLayer('myBox').removeLayer('myBox2');    // [<canvas>​]
MyObj.canvas.getLayers().length;                            // 0

And with v5.4:

MyObj.canvas.addLayer({ method:'drawRect', name:'myBox', fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.addLayer({ method:'drawRect', name:'myBox2', fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.getLayers().length;                            // 2
MyObj.canvas.getLayer('myBox');                             // E
MyObj.canvas.getLayer('myBox2');                            // E
MyObj.canvas.removeLayer('myBox').removeLayer('myBox2');    // TypeError: Cannot call method 'removeLayer' of undefined

I'd initially thought it was failing as no layer existed with the name I was trying to remove - but it happens when removing layers that are present as well.

Dan

@caleb531
Copy link
Owner

caleb531 commented Jun 9, 2012

Wow, how did I miss that? :/

Anyway, it's fixed now. The fixed build should already be on GitHub.

-Caleb

On Sat, Jun 9, 2012 at 7:56 AM, BillyRayPreachersSon <
reply@reply.github.com

wrote:

It seems that when using v5.4, you can'tt chain calls to removeLayer.
Here's my test code from Issue #18:

var MyObj = {
       canvas: $('<canvas />'),

       addLayer: function() {
               this.canvas.addLayer(this.drawLines);
       },

       drawLines: function lines(ctx) {
               console.log('MyObj.drawLines is being called');
               console.log('"this" context = ', this);
       }
}

Here's what I see when using v5.3.1:

MyObj.canvas.addLayer({ method:'drawRect', name:'myBox', fillStyle:'#585',
x:100, y:100, width:100, height:50 });
MyObj.canvas.addLayer({ method:'drawRect', name:'myBox2',
fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.getLayers().length;
             // 2
MyObj.canvas.getLayer('myBox');
              // Object
MyObj.canvas.getLayer('myBox2');
             // Object
MyObj.canvas.removeLayer('myBox').removeLayer('myBox2');        //
[<canvas>​]
MyObj.canvas.getLayers().length;
             // 0

And with v5.4:

MyObj.canvas.addLayer({ method:'drawRect', name:'myBox', fillStyle:'#585',
x:100, y:100, width:100, height:50 });
MyObj.canvas.addLayer({ method:'drawRect', name:'myBox2',
fillStyle:'#585', x:100, y:100, width:100, height:50 });
MyObj.canvas.getLayers().length;
             // 2
MyObj.canvas.getLayer('myBox');
              // E
MyObj.canvas.getLayer('myBox2');
             // E
MyObj.canvas.removeLayer('myBox').removeLayer('myBox2');        //
TypeError: Cannot call method 'removeLayer' of undefined

I'd initially thought it was failing as no layer existed with the name I
was trying to remove - but it happens when removing layers that are present
as well.

Dan


Reply to this email directly or view it on GitHub:
#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants