Coder Social home page Coder Social logo

Comments (6)

danro avatar danro commented on July 22, 2024

Why not use start() to start it back up again?

from tram.

weotch avatar weotch commented on July 22, 2024

Here's my use case: https://gist.github.com/weotch/9494115#file-view-js

It's for a carousel slider. I want to set the old slide to display:none after the new slide has finished transitioning. But if you're spamming clicks, the then() never gets fired. Here's me trying what I think you're talking about: https://gist.github.com/weotch/9494115#file-workbench-js

But that didn't solve it for me. Am I missing your point?

from tram.

danro avatar danro commented on July 22, 2024

In that case, I would suggest some sort of cleanup function that filters out the non-current slides and sets them to display:none, so you can call it after the current queue has finished.

from tram.

weotch avatar weotch commented on July 22, 2024

I think I'll do this, just not use then() in this case.

// Change the page
View.change = function(e, new_page) {

    // Make sure old page has lower z-index and stop any trams.
    // Note: calling set() invokes stop()
    var old = this.$slides.eq(e.previous('page')).tram()
        .set({'z-index': 1})
    ;

    // Hide the old one after the transition is done.  Don't use
    // then() because it won't be fired if the animation is stopped.
    _.delay(function() {
        old.set({display: 'none'});
    }, 300);

    // Animate in new page
    this.$slides.eq(new_page).tram()
        .add('opacity 300ms')
        .set({ display: 'block', opacity: 0, 'z-index': 2} )
        .start({ opacity: 1})
    ;

};

Feel free to close the ticket if this isn't something you think is needed in tram.

from tram.

danro avatar danro commented on July 22, 2024

You could also use the tram.delay utility to ensure the timing stays in sync with the animations:

tram.delay(300, function () {
  // Hide non-current slides, but remember when this executes, the current slide may be changed ;)
});

from tram.

weotch avatar weotch commented on July 22, 2024

Oh, thanks for the tip.

from tram.

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.