Git Product home page Git Product logo

Comments (5)

Vestride avatar Vestride commented on August 25, 2024

Yes they are limited intentionally to only trigger one layout or shrink event. The callback option is private. Use the events that are triggered instead.

from shuffle.

klihelp avatar klihelp commented on August 25, 2024

Events could have other subscribers, but callback is only limited to the current transition.
The transition() function is a really nice, it's takes care of css3/js transitions.
I was able to replace box content having fadeOut/fadeIn effect using transition() with callback.

  • achieve this effect without callback() is not possible using transition()
  • and without transition() it will be a challenge to create a custom function which is already in shuffle() and managing css3 and javascript opacity transitions.

I read your comment in the other thread that transition() intended as a private method. This is maybe because callback() exposes the this.Shuffle object. Can you keep it public and open up a safer callback()?
Eg. See code bellow, callback() could fire on opts.from == action_ or custom_ or public_ prefix values; like action_todo_list

// Fire callback() on opts.from == action_ prefixes
// Rewritten to switch;

complete = function() {
    switch (opts.from) {
        case 'layout':
            if (!self.layoutTransitionEnded) {
                self._fire(Shuffle.EventType.LAYOUT);
                opts.callback.call(self);
                self.layoutTransitionEnded = true;
            }
            break;
        case 'shrink':
            if (!self.shrinkTransitionEnded) {
                opts.callback.call(self);
                self.shrinkTransitionEnded = true;
            }
            break;
    }
    if (opts.from.indexOf('action_') === 0 && typeof opts.callback == "function") {
        // safer public callback() without exposing Shuffle object
        // and only give back $this element
        opts.callback.call(opts.$this);
    }
}

from shuffle.

klihelp avatar klihelp commented on August 25, 2024

Just as an app update, my workable block-content-replace with fadeIn/out effect looks like this:

$grid.shuffle.transition({
    from: 'action_fadeOut',
    $this: $current.addClass(newBlockClasses),
    opacity: 0,
    callback: function() {
        $grid.shuffle.transition({
            from: 'action_fadeIn',
            // $this: $current.html($newblock.html()), 
           // we got back opts.$this
            $this: this.html($newblock.html()),
            opacity: 1,
            callback: $grid.shuffle.layout()
        });
    }
})

Example:
http://plnkr.co/fIzWQ5rehi8u389cSdbt

from shuffle.

Vestride avatar Vestride commented on August 25, 2024

The transition method isn't meant to be a utility function for other uses. If you require the ability to animate opacity and other properties with css transitions, you should look into jQuery Transit

from shuffle.

klihelp avatar klihelp commented on August 25, 2024

I accept your decision.
Thank you for the nice shuffle plugin, really nice work!

from shuffle.

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.