Giter VIP home page Giter VIP logo

Comments (3)

jakiestfu avatar jakiestfu commented on June 7, 2024

Couldn't you do something like this? Or do they get replaced?

snapper.on('drag', myFunc);
snapper.on('drag', anotherFunc);

If the drag function does get replaced, I want to keep the weight of this library down as much as possible because it's goal is rather small, (open the menu. that's it, hehe), so I don't want to bloat the library.

What about doing something like this?

snapper.on('drag', function(){
    myFunc.call();
    anotherFunc.call();
});

Thoughts?

from snap.js.

pgherveou avatar pgherveou commented on June 7, 2024

i am listening on the animated event to hide/show left or right drawer
but in some scenario I also need to know when the event animated is fired to replace or destroy the content of the drawer. so I do something like that in my updated version

snapper.once('animated', function() {view.dispose();});

nice thing with component.js is that dependencies are shared, thus not impacting global file size
but I understand not everybody is using it ;-) and that you don't want to add dependencies to Snap.js

from snap.js.

jakiestfu avatar jakiestfu commented on June 7, 2024

I think I am going to leave it the way it is for now, it's current state should allow you to do what you need to. You'd just need to check in your code if your view actually needs to be disposed, and if it has been, you can do the following:

var view = {
    dispose: function(e){
        if(needsToDispose){
            snapper.off('animated');
            // Dispose shiet
        }
    }
};

snapper.on('animated', view.dispose);

from snap.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.