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

Initializing sequence after ajax injection / dynamic page #278

Open
johanneslamers opened this issue Jun 6, 2016 · 0 comments
Open

Initializing sequence after ajax injection / dynamic page #278

johanneslamers opened this issue Jun 6, 2016 · 0 comments

Comments

@johanneslamers
Copy link

johanneslamers commented Jun 6, 2016

I'm using SmoothState on a website. Most of the content will be injected with ajax. SmoothState provides me with some hooks:

  • onBefore - Runs before a page load has been started
  • onStart - Runs once a page load has been activated
  • onProgress - Runs if the page request is still pending and the onStart animations have finished
  • onReady - Run once the requested content is ready to be injected into the page and the previous animations have finished
  • onAfter - Runs after the new content has been injected into the page and all animations are complete

For testing I'm using your test theme with the detroy and init buttons. It works just a normal with a regular page load. With the 2 buttons I can manually destory and init sequence.js. But not after an ajax injection. What am I doing wrong?

function initSequence() {
    if ($('#sequence').length) {
        mySequence = sequence(sequenceElement, sequenceOptions);
        console.log("init Sequence");
    };
}

function destroySequence() {
    if ($('#sequence').length) {

        if (mySequence !== undefined) {
            mySequence.destroy();
            mySequence = undefined;
        }
        console.log("destroy Sequence");
    };
}

$("#init").on('click', function() {
    initSequence();
});

$("#destroy").on('click', function() {
    destroySequence();
});


.... // smoothState setup

    onAfter: function ($container, $newContent) {
        initPage();
    },
    smoothState = $page.smoothState(options).data('smoothState');

... // etc etc smoothState setup


var initPage = function() {
    initSequence();
};


$(document).ready(function() {
    initPage();
});
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

1 participant