jmpressjs / jmpress.js

A jQuery plugin to build a website on the infinite canvas
http://jmpressjs.github.com/jmpress.js
1.5k stars 237 forks source link

Change slide on click, with part-time solution #113

Closed odugen closed 11 years ago

odugen commented 11 years ago

I was trying to change slide on click event.

Code worked when called from console, but failed when called by event handler.

Ended up with commenting out following lines

Look like hack, but hope it will save some time for others.

    /* HOOKS */
    $jmpress("afterInit", function( nil, eventData ) {
        //var settings = eventData.settings,
        //  stepSelector = settings.stepSelector,
        //  current = eventData.current,
        //  jmpress = $(this);
        //current.clickableStepsNamespace = ".jmpress-"+randomString();
        //jmpress.bind("click"+current.clickableStepsNamespace, function(event) {
        //  if (!settings.mouse.clickSelects || current.userZoom) {
        //      return;
        //  }

        //  // get clicked step
        //  var clickedStep = $(event.target).closest(stepSelector);

        //  // clicks on the active step do default
        //  if ( clickedStep.is( jmpress.jmpress("active") ) ) {
        //      return;
        //  }

        //  if (clickedStep.length) {
        //      // select the clicked step
        //      jmpress.jmpress("select", clickedStep[0], "click");
        //      event.preventDefault();
        //      event.stopPropagation();
        //  }
        //});
    });
    $jmpress('afterDeinit', function( nil, eventData ) {
        //$(this).unbind(eventData.current.clickableStepsNamespace);
    });
sokra commented 11 years ago

No need to comment the lines as there is an option: settings.mouse.clickSelects which disables slide on click.


But I the problem that code doesn't work in the event handler is that you don't prevent bubbling in the handler. Add a return false; to the handler (jquery). This prevents from bubbling to slide on click.