Code Monkey home page Code Monkey logo

Comments (6)

ctrlmaniac avatar ctrlmaniac commented on May 29, 2024

There isn't such a feature yet and I think that by now I am not able to add it! When I will manage to do it, I will certainly add it! Some help would be great!

simple-sidebar and simpler-sidebar are developed at the simple-sidebar organization, since I want to move there all sidebars repos!

from sidebar.

ericandrewscott avatar ericandrewscott commented on May 29, 2024

Updated the main JS file and ran it through your linter via grunt.... here's the PR: #22

Now you could run some extra JS in an application by using something like:

        $( 'body' ).on( 'open.panel', function (e) {
            // do some stuff
        });

or:

        $( 'body' ).on( 'close.panel', function (e) {
            // do some stuff
        });

from sidebar.

ctrlmaniac avatar ctrlmaniac commented on May 29, 2024

The code would be changed to be a fully functional plugin. In your way the event driven callbacks will be available for all instances instead of being able for the instance of the object.
I will add this functionality soon. I'm already working on it, but in the jquery plugin way:

$sidebar.simplerSidebar( {
  // Other Options
  callbacks: {
    onClose: function() {},
    onOpen: function() {}
  }
} );

from sidebar.

ericandrewscott avatar ericandrewscott commented on May 29, 2024

@dcdeiv that works for me. I only have one instance of the sidebar in my application, but ideally, you're right!

from sidebar.

ericandrewscott avatar ericandrewscott commented on May 29, 2024

👍

from sidebar.

ctrlmaniac avatar ctrlmaniac commented on May 29, 2024

This is now possible in v2.0.2.
Quoting the changelog:

3 - Add the ability to set custom functions to run when/after all the animations are triggered. #21-#22

In the options there is a brand new feature: events. This wrapper will handle all your functions according to some events that occur in the plugin. By now I have added only the animation event.

You can add some custom functions to be triggered when/after the animations.

  • events.on.animation will handle all your custom functions that must be run when the animation is triggered.
  • events.callbacks.animation will handle all your custom functions that must be run after the animation has been triggered.
  • open in the animation that opens the sidebar.
  • close is the animation that closes the sidebar.
  • both will run your custom functions on both animations.
var callopen = function() {
        alert( "callback called after the sidebar's been opened" );
    },
    callclose = function() {
        alert( "callback called after the sidebar's been closed" );
    },
    callboth = function() {
        alert( "callback called after both animations" );
    },
    onopen = function() {
        alert( "function called while the sidebar is opening" );
    },
    onclose = function() {
        alert( "function called while the sidebar is closing" );
    },
    onboth = function() {
        alert( "function called while both animations are triggered" );
    };

$( "#sidebar" ).simplerSidebar( {
    // Required options are skipped in this example
    events: {
        on: {
            animation: {
                open: onopen,
                close: onclose,
                both: onboth
            }
        },
        callbacks: {
            animation: {
                open: callopen,
                close: callclose,
                both: callboth
            }
        }
    }
} );

from sidebar.

Related Issues (19)

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.