Khan / Prototope

Swift library of lightweight interfaces for prototyping, bridged to JS
http://khan.github.io/Prototope
230 stars 18 forks source link

Behaviors can't be removed #17

Closed andymatuschak closed 9 years ago

andymatuschak commented 9 years ago

@may-li and I noticed today that if we set a layer's behaviors list to a list which excludes a previously added behavior, that behavior isn't actually removed. Looks like that logic is missing from BehaviorDriver.updateWithLayer().

@saniul, would you be willing to take a look? If not, no worries at all!

saniul commented 9 years ago

Ah, yes, will do

may-li commented 9 years ago

Yay! Thank you!!

On Feb 13, 2015, at 7:28 PM, Saniul Ahmed notifications@github.com wrote:

Ah, yes, will do

— Reply to this email directly or view it on GitHub.

saniul commented 9 years ago

Weird, can’t seem to reproduce, at least naively:

        self.catLayer.behaviors = [ActionBehavior { layer in
                Layer.root.backgroundColor = Color.red
            }]
        self.catLayer.behaviors = [CollisionBehavior(with: rainbowLayer) { kind in
            switch kind {
            case .Entering:
                self.makeSparkle(self.catLayer)
            default:
                ()
            }
        }]

(the background never gets set to red, if you put a breakpoint in the first behavior – it never gets triggered)

@andymatuschak @may-li mind sharing a scene which exhibits this bug?

andymatuschak commented 9 years ago

Nope, I'm full of crap. You're right, @saniul!

@may-li, we must have been hitting a different problem! Hm hm.