Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Previous/Back, not triggering #1

Open
Martin-Pitt opened this issue Nov 21, 2016 · 1 comment
Open

Previous/Back, not triggering #1

Martin-Pitt opened this issue Nov 21, 2016 · 1 comment

Comments

@Martin-Pitt
Copy link

From the demo it seems that going backwards doesn't trigger correctly? E.g. fragment two, back and it doesn't show fragment one

@davedupplaw
Copy link

I've just been using this to zoom around an SVG and found the same problem. I got around it by changing the fragment definition from a single function to an object with two functions: one for show and one for hide. I edited the fragments method to register the hide function too:

    SlideBuilder.prototype.fragments = function (callbacks) {
        var self = this;
        callbacks.forEach(function (obj) {
            let frag = self.addFragment();
            frag.addEventListener('shown', obj.show);
            frag.addEventListener('hidden', obj.hide);
        });

        return this;
    };

Then you have to define both the forward and backward movements, e.g:

new SlideBuilder(element).fragments([ {
      hide: () => element.style.transform = 'scale(1.0) translateX(0)',
      show: () => element.style.transform = 'scale(3.8) translateX(-650px)'
} ])

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants