ArthurClemens/mithril-page-slider

velocityjs support (feature)

Closed this issue ยท 2 comments

Hi @ArthurClemens ! really nice work ๐Ÿ‘

I'm using your library in a mobile project and is working great.

What do you think about give it support to create custom transitions with velocityjs?
For example something like:

import pageSlider from 'mithril-page-slider';
import Velocity from 'velocity-animate';

pageSlider.use(Velocity);

const slider = (page) => {
    return m.component(pageSlider, {
        page: page,
        enter: {
            props: {}, // can be properties or an string effect of the ui pack
            opts: {} // options like `duration`
        },
        leave: {
            props: {},
            opts: {}
        }
    });
};

m.route(document.body, '/', {
    '/': slider(home),
    '/page1': slider(page1),
    '/page2': slider(page2)
});

I didn't want to add Velocity as a dependency (with 12.5K gzipped), while my impression is that it is just a wrapper around CSS animations. Can you show an example that demonstrates its advantage?

i don't mean use as a dependency, i mean use as an optional extension but yes you are right about Velocity in some point. For transitions is a better choice use CSS.

About the advantage (in some cases) of VelocityJS vs CSS you can read this: http://davidwalsh.name/css-js-animation