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

Rework macros to be used as static tram properties. #1

Closed
danro opened this issue Apr 8, 2013 · 10 comments
Closed

Rework macros to be used as static tram properties. #1

danro opened this issue Apr 8, 2013 · 10 comments

Comments

@danro
Copy link
Collaborator

danro commented Apr 8, 2013

Macros should be reworked a bit.

Instead of strings, I think they'd be more useful like this:

tram(element)
  .start({ x: 200, opacity: 0 })
  .then(tram.hide);

or

tram(element)
  .start(tram.slideDown)
  .then(tram.slideUp)
  .then(function () { console.log('done') });
@danro
Copy link
Collaborator Author

danro commented Apr 24, 2013

@weotch check out the above spec ^ .. does that work for your auto-hide request?

tram also now has a show() shortcut as well. so you can do this:

tram(element).show().start({ etc })

@weotch
Copy link
Member

weotch commented Apr 24, 2013

In your show() example, will it defer the start so you still see the animation? Rather than that annoying css3 thing where if you toggle display:none on the same tick as a transition it doesn't show?

@danro
Copy link
Collaborator Author

danro commented Apr 24, 2013

@weotch of course, man ;) every start() is actually deferred a single animation frame.

hide() is also smart in that it stops the tram before setting display: none.

@danro
Copy link
Collaborator Author

danro commented Apr 24, 2013

Here's a test showing how tram works with display: none. http://bkwld.github.io/tram/test/display-none.html

@weotch
Copy link
Member

weotch commented Oct 22, 2013

Was thinking of finally making some macros. Is the API for them gonna change you think?

@danro
Copy link
Collaborator Author

danro commented Oct 22, 2013

@weotch currently there are no macros... we'd need to define how that works.

@weotch
Copy link
Member

weotch commented Oct 22, 2013

macross_original_logo

@danro
Copy link
Collaborator Author

danro commented Oct 22, 2013

Exactly. I do like the idea of the thenHide helper method.

@weotch
Copy link
Member

weotch commented Oct 23, 2013

Regarding defining how it works, what about an API like:

// Define it.  `tram` is the AMD module
tram.macro('fadeOut', function() { this.add('opacity 300ms').start({opacity:0}).then(function() { this.hide(); }); });

// Use it
$el.tram().macro('fadeOut');

Note: I edited this

@danro
Copy link
Collaborator Author

danro commented Jan 24, 2014

Been thinking more about macros, and I don't think we need to write any code to support them. Tram already supports passing functions to the start() method. Here's an example of a "fadeOut macro" with a customizable time value:

tram(el, fadeOut(800));

function fadeOut(time) {
  if (time == null) time = 500;
  return function () {
    this
    .add('opacity ' + time)
    .start({ opacity: 0 })
    .then(function () {
      this.hide();
    });
  };
}

Working jsbin example here.

@danro danro closed this as completed Jan 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants