Giter VIP home page Giter VIP logo

Comments (8)

samselikoff avatar samselikoff commented on July 23, 2024

(If I had to take a stab, my best guess is so transitions are pure and thus can be reused.)

My use case at the moment (for which I'm trying to think through a better solution) is clicking an item in a list. Doing that reshuffles the list, so all sprites are keptSprites, but I want the clickedItem to be animated in a slightly different way from the others. I'm having trouble figuring out how to do that.

from ember-animated.

ef4 avatar ef4 commented on July 23, 2024

Right, they are functions, not methods. You can manually bind them if you want to, like any function.

export default Component.extend({
  init() {
    this._super.init();
    this.transition = this.transition.bind(this);
  },

  foo: 'bar',

  * transition({ keptSprites }) {
    console.log(this);
    keptSprites.forEach(sprite => {

from ember-animated.

samselikoff avatar samselikoff commented on July 23, 2024

I see... is that considered a bad practice?

from ember-animated.

samselikoff avatar samselikoff commented on July 23, 2024

I might still be "thinking in D3" but I think my higher-level question is how to "link" Sprites with the objects/data that's driving them.

Simple demo I'm hacking on:

Kapture 2019-03-15 at 7 18 30

Clicking an item changes its position property and the list resorts. What if I want to do something "special" to the clicked item? Basically if I bound my transition function in init, maybe I could use some data-item-id attr on the dom element to look up the correct item from the this.items array, and use that to affect the animation. But it almost feels like there should be a direct way to "bind" some data to a Sprite.

from ember-animated.

ef4 avatar ef4 commented on July 23, 2024

I don't think it's bad.

We could choose to introduce sprite.model. There is a user-provided model backing every sprite, it's just not exposed in the API today.

from ember-animated.

samselikoff avatar samselikoff commented on July 23, 2024

There is a user-provided model backing every sprite

Could you elaborate?

from ember-animated.

samselikoff avatar samselikoff commented on July 23, 2024

Is it the predicate, the thing that is changing that is triggering a Sprite to animate?

from ember-animated.

ef4 avatar ef4 commented on July 23, 2024

Yes, it's the value that's yielded into the block. For animated-if it's just the value of the predicate, but for a-value or a-each it's the value of the actual item.

from ember-animated.

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.