Comments (13)
ng generate app year-of-moo-animation --skip-tests --style=scss --dry-run
ng generate component components/index --flat=false --module=app --project=year-of-moo-animation --spec=false --styleext=scss --dry-run
ng generate component components/use-animation --flat=false --module=app --project=year-of-moo-animation --spec=false --styleext=scss --dry-run
ng generate component components/animation-builder --flat=false --module=app --project=year-of-moo-animation --spec=false --styleext=scss --dry-run
from unicorn-whale.
to switch apps for npm start
the defaultProject
config setting (in angular.json
) has to be set; to check the current value:
ng config defaultProject
to set the value:
ng config defaultProject year-of-moo-animation
from unicorn-whale.
boom:
from unicorn-whale.
not managing players properly :(
from unicorn-whale.
i've noticed that @matsko never uses AnimationPlayer.reset()
in his entire demo repository; in his sole example, showing the use of AnimationBuilder
, he has a method, animateTo()
that appears to not reuse instances of AnimationPlayer
when @matsko uses the term reusable he is almost always referring to reusable AnimationReferenceMetadata
not reusable AnimationPlayer
instances; nevertheless there is a reason why methods reset()
and setPosition(0)
exist on AnimationPlayer
from unicorn-whale.
the animation-builder
demo is not working at all on Chrome; simultaneously a warning message in the console on Edge suggest that web-animations-js
[NPM] is required
from unicorn-whale.
this is the pattern that is working:
slideBack(): void {
this.photos.forEach(img => {
const player = this.getImgPlayer(slideBackAnimation, img);
player.play();
});
}
slideForward(): void {
this.photos.forEach(img => {
const player = this.getImgPlayer(slideForwardAnimation, img);
player.play();
});
}
previously, i tried to store AnimationPlayer[]
in a private field in order to loop through each and play()
but this did not work on Chrome
my concern however is that these local instances of player might be stacking up in memory; i thought i was being clever by doing this:
player.onDone(() => player.destroy());
but this throws errors likely due to race conditions (then there is a temptation to delay the call with something like setTimeout
but this feels like playing games)
from unicorn-whale.
this 'game' is working:
player.onDone(() => {
console.log(`player ${player['id']} done`, player);
setTimeout(() => player.destroy(), 500);
});
however, the final animation state is destroyed when the player is destroyed
more context around the above:
private getPlayer(
animationMetadata: AnimationReferenceMetadata,
el: Element
): AnimationPlayer {
const factory = this.animationBuilder.build(animationMetadata);
const x = el.clientWidth / 2;
const player = factory.create(el, { params: { x: x } });
player.onDestroy(() => console.log(`player ${player['id']} destroyed`));
player.onDone(() => {
console.log(`player ${player['id']} done`, player);
setTimeout(() => player.destroy(), 500);
});
return player;
}
from unicorn-whale.
quick look at the reset()
method:
this move does not pop the element back to where it started the animation on Edge—on Chrome it is fine:
player.onDone(() => {
console.log(`player ${player['id']} done`, player);
setTimeout(() => player.reset(), 500);
});
this is telling me, i need to resolve #8
from unicorn-whale.
for this particular example the goal post will be moved to show both of these scenarios:
- reusing an animation player
- using an animation player once (and destroying it before it is replaced)
the latter scenario is important when AnimationOptions.params
need to change frequently for a given animation
from unicorn-whale.
this approach is not working:
slideDivBack(): void {
const player = this.simpleBlockAnimationMeta.slideBackPlayer;
if (player.hasStarted()) {
player.reset();
}
player.play();
}
slideDivForward(): void {
const player = this.simpleBlockAnimationMeta.slideForwardPlayer;
if (player.hasStarted()) {
player.reset();
}
player.play();
}
from unicorn-whale.
another approach: exclusively address the concern of using an animation player once (and destroying it before it is replaced)
the arguments passed to getPlayer()
should contain a unique ID; this unique ID should be saved in a private array of { id: string, player: AnimationPlayer }
the catch is around generating the unique ID
from unicorn-whale.
this latest strategy appears to be working:
from unicorn-whale.
Related Issues (15)
- npm audit log HOT 1
- run `ng generate app <name>` for the first time HOT 2
- run `ng generate lib` for the first time HOT 3
- build out “Animation Examples in Angular 4.3” HOT 3
- consider moving your “Tour of Heroes” sample to this repo
- disable the `no-console` rule?
- @angular/animations: please load the web-animations.js polyfill to allow programmatic access HOT 1
- translate “responsive strip of fixed inline blocks” CodePen HOT 8
- explore “Testing with the Angular HttpClient API” by Ciro Nunes HOT 3
- migrate samples to 7.x workspace
- follow “Unit testing of simple input box” by Julia Passynkova HOT 1
- `nx-workspace-menu` needs to be a shared lib
- can a SEO-effective splash screen be made out of Angular's conventional `index.html`? HOT 7
- does `Renderer2` help with any `@ViewChild` manipulations here?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unicorn-whale.