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

Overwrite jmpress function #177

Open
mkbrv opened this issue Jan 22, 2015 · 2 comments
Open

Overwrite jmpress function #177

mkbrv opened this issue Jan 22, 2015 · 2 comments

Comments

@mkbrv
Copy link

mkbrv commented Jan 22, 2015

Considering the cube example:
http://jmpressjs.github.io/jmpress.js/examples/cube/#/front

var cube = $('#cube');
$.jmpress("register", "up", function() {
    var stepData = cube.jmpress("active").data("stepData");
    if(stepData.up)
        cube.jmpress("select", stepData.up);
});

Using AngularJS routing (or simple ajax to bring different views), rebuilding a slider like the one presented above will not work since I cannot overwrite an event.

/**
     * Register a callback or a jmpress function
     *
     * @access public
     * @param name String the name of the callback or function
     * @param func Function? the function to be added
     */
    function register(name, func) {
        if( $.isFunction(func) ) {
            if( methods[name] ) {
                $.error( "function " + name + " is already registered." );
            } else {
                methods[name] = func;
            }
}
@FagnerMartinsBrack
Copy link

@mikibrv
Do you know a good port or wrapper of jmpress for angular? I started an angular jmpress wrapper for personal purposes because I didn't find any: https://github.com/web-stories/angular-jmpress

@mkbrv
Copy link
Author

mkbrv commented Jan 26, 2015

@FagnerMartinsBrack

I only wrapped angular in a directive:
https://github.com/mikibrv/angular-with-grunt/blob/master/src/app/common/jmpress/cube.directive.js

If I would like to dynamically add/remove a slide I can just set a watch for a specific variable and call a method storing the reference to the jmpress object.

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