Commit graph

203 commits

Author SHA1 Message Date
Jessica Janiuk
70332b0453 fix(core): pass element removal property through in all locations (#64565)
The `requireSynchronousElementRemoval` property was not being passed in all the locations it was needed. This was preventing leave animation timing from behaving properly in some cases.

fixes: #64525

PR Close #64565
2025-10-21 18:08:34 +00:00
JoostK
2b257b3659 fix(animations): account for Element.animate exceptions (#64506)
In certain scenarios `Element.animate` fails, manifesting in an exception (Firefox)
or a null return value (Chromium). The null value is not conform WebIDL but handled
gracefully in this commit regardless.

Closes #64486

PR Close #64506
2025-10-21 16:49:42 +00:00
Jessica Janiuk
dde5badb71 fix(core): prevent animations renderer from impacting animate.leave (#63921)
This adds an optional flag to the renderer on `removeChild` called `requireSynchronousElementRemoval`, which can tell any downstream renderer that elements need to be removed synchronously. This gets passed down to the legacy animation renderer to ensure that any elements that set this flag aren't impacted by that renderers changes to timing.

fixes: #63893

PR Close #63921
2025-09-19 21:26:18 +00:00
Jessica Janiuk
9766116cea refactor(animations): deprecate the animations package (#62795)
This deprecates the animations package in favor of using `animate.enter` and `animate.leave` with intent to remove the full package in v22.2.

DEPRECATED: @angular/animations

PR Close #62795
2025-07-29 09:50:09 +00:00
arturovt
7aae854f5e refactor(animations): mark non-default new expressions as pure (#61452)
Adds `__PURE__` annotations to non-default `new` expressions to enable tree-shaking, even if they are not referenced. These variables are not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #61452
2025-05-19 08:26:56 +00:00
Andrew Kushnir
006a14da89 refactor(animations): convert scripts within packages/animations to relative imports (#60230)
This commit updates scripts within `packages/animations` to relative imports as a prep work to the upcoming infra updates.

PR Close #60230
2025-03-27 18:28:01 +00:00
Kristiyan Kostadinov
b76be83b4d fix(core): animation sometimes renderer not being destroyed during HMR (#59574)
These changes aim to resolve the issue that prompted #59514. The animations module is a bit tricky for HMR, because it schedules the destruction of its renderer after the currently-running animations are done. If there are no running animations, the renderer gets destroyed next time around. This is a problem, because it means that the styles can stay around for a long time.

These changes resolve the issue by:
1. Moving the cleanup of the renderer to after the destruction of the old view. This ensures that the usual clean up flow has been kicked off.
2. Flushing the animations when a component is replaced to ensure that the renderer is cleaned up in a timely manner.

PR Close #59574
2025-01-16 11:36:43 -08:00
arturovt
5884153e12 refactor(animations): drop warning functions in production (#59408)
Prior to this commit, functions that issued warnings were not wrapped with `ngDevMode` at the point
of invocation but had the `ngDevMode` check inside. This meant they acted as no-ops in production.
In this commit, we wrap them externally with `ngDevMode`, so they are entirely removed.

PR Close #59408
2025-01-09 13:15:06 -05:00
Kristiyan Kostadinov
0e23f20c41 fix(platform-browser): styles not replaced during HMR when using animations renderer (#59393)
When we replace a component during HMR, we clear it from the cache of the renderer factory, however when using animations, there's an animation-specific renderer factory that wraps the base DOM one and was preventing the cache from being cleared.

These changes rework the logic that clear the cache to go through a method so we can forward the call to the delegated factory.

PR Close #59393
2025-01-07 15:55:38 +00:00
Kristiyan Kostadinov
d010e11b73 feat(core): add event listener options to renderer (#59092)
Updates the `Renderer2.listen` signature to accept event options, as well as all adjacent types to it.

PR Close #59092
2024-12-10 13:39:47 -08:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Kristiyan Kostadinov
513a4fe05e refactor(core): replace usages of removeChild (#57203)
These changes replace most usages of `removeChild` with `remove`. The latter has the advantage of not having to look up the `parentNode` and ensure that the child being removed actually belongs to the specific parent.

The refactor should be fairly safe since all the browsers we cover support `remove`. [Something similar was done in Components](https://github.com/angular/components/pull/23592) some time ago and there haven't been any bug reports as a result.

PR Close #57203
2024-08-07 16:46:09 +00:00
Andrew Scott
024e9bf54d refactor(core): Ensure animations are flushed before running render hooks (#55564)
This commit ensures we flush animations by calling renderFactory
begin/end in cases where the ApplicationRef._tick happens in a mode that
skips straight to the render hooks.

PR Close #55564
2024-04-30 15:39:56 -07:00
Andrew Scott
bf8814c6c3 refactor(core): Omit listeners from out-of-zone scheduling when using ZoneJS (#55492) (#55525)
In Angular today, a bound listener automatically marks the view for
check. When using ZoneJS, these listeners are most often executed in the
Angular Zone as well, so synchronization (`ApplicationRef.tick`) will
eventually happen. _However_, developers can opt out of zone-patching
for events in several ways, and often do this for very frequent
listeners like `mousemove`, `resize`, and `scroll`. We do not want to
break existing expectations that these are now "safe" events to have
listeners for by automatically scheduling change detection regardless of
whether the listener executed inside or outside the Angular zone.

In contrast, in order for developers to more easily transition to zoneless,
we need to be able to ensure that components which are using `OnPush`
are, for the most part, compatible with zoneless as well. Because listeners
automatically mark the component for check, developers using `OnPush`
did not/do not need to also call `ChangeDetectorRef.markForCheck` or a
similar API. Unfortunately, this means that we need to consider the
listener callbacks as a notification to schedule a `tick` when Zoneless
is enabled. In the future, we would like to have an opt-out for this
(i.e. signal components) since it's not really how we _want_ things to work.

Also includes the fix for #54919 that got reverted only because it was
easier to revert the set of conflicting commits

PR Close #55525
2024-04-25 12:56:37 -07:00
Andrew Kushnir
e3d5607caf Revert "refactor(core): Ensure DOM removal happens when no app views need refresh (#55132)" (#55524)
This reverts commit a07ea069e5.

PR Close #55524
2024-04-24 16:35:57 -07:00
Andrew Kushnir
28905ab9ae Revert "refactor(animations): Ensure async animations applies changes when loaded in zoneless (#55132)" (#55524)
This reverts commit 9ab36cfe0a.

PR Close #55524
2024-04-24 16:35:57 -07:00
Andrew Scott
9ab36cfe0a refactor(animations): Ensure async animations applies changes when loaded in zoneless (#55132)
Async animations currently works in Zones because the render factory
promise resolve causes change detection to happen.

fixes #54919

PR Close #55132
2024-04-24 10:33:47 -07:00
Andrew Scott
a07ea069e5 refactor(core): Ensure DOM removal happens when no app views need refresh (#55132)
This change ensures that `ApplicationRef.tick` flushes animations by
calling `rendererFactory2.end`. This might not have happened before if
there were no views that needed to be refreshed.

This is also likely to fix a potential regression caused by #53718 even
in zone apps where animations don't get flushed when no views attached
to ApplicationRef are dirty.

PR Close #55132
2024-04-24 10:33:47 -07:00
Alan Agius
bcce85af72 refactor(animations): remove deprecated matchesElement from AnimationDriver (#55479)
BREAKING CHANGE: Deprecated `matchesElement` method has been removed from `AnimationDriver` as it is unused.

PR Close #55479
2024-04-23 13:06:27 -07:00
Joey Perrott
bbbe477f47 refactor: migrate animations to prettier formatting (#53977)
Migrate formatting to prettier for animations from clang-format

PR Close #53977
2024-01-19 20:08:57 +01:00
Andrew Scott
5ae85e4849 refactor(core): node removal notifies scheduler only when animations are enabled (#53857)
Node removal is immediate and does not require change detection to run
when animations are not provided. This refactor makes the animation
engine notify the scheduler rather than doing it on all node removals.

PR Close #53857
2024-01-19 10:28:24 +01:00
Matthieu Riegler
d7e7409e81 refactor(animations): drop convertToMap & copyStyles and use native functions. (#52441)
`copyStyles` was side-effectful and also returned a value : not great.

PR Close #52441
2023-12-14 12:33:24 -08:00
Matthieu Riegler
d28ce0a4cf refactor(animations): use a spread operator instead of custom copyObj (#52441)
Using the spread operator is the fastest way to shallow copy an object.

PR Close #52441
2023-12-14 12:33:24 -08:00
Matthieu Riegler
635c3b4fa8 refactor(animations): use existing helper methods. (#52441)
Saving a few bytes.

PR Close #52441
2023-12-14 12:33:24 -08:00
arturovt
a02a745a4a fix(animations): remove finish listener once player is destroyed (#51136)
This commit removes the `finish` listener from the Animation object once
the animation is finished, effectively resolving a memory leak. Previously,
the `finish` listener captured `this`, which prevented `this` from being garbage collected.

PR Close #51136
2023-11-02 10:29:38 -07:00
Matthieu Riegler
1c4a3677eb refactor(animations): make AnimationBuilder tree-shakable (#52097)
This commit allows also to use the `AnimationBuilder` when using `provideAnimationsAsync()`

fixes #52096

PR Close #52097
2023-10-12 18:13:22 +02:00
Matthieu Riegler
75d610d420 fix(platform-browser): set animation properties when using async animations. (#52087)
Animations properties set on the default renderer weren't set on the animation renderer once it was loaded. This commit fixes this.

PR Close #52087
2023-10-10 11:59:13 -07:00
Matthieu Riegler
5b375d106f fix(platform-browser): Fire Animations events when using async animations. (#52087)
Animations events registered against the default renderer weren't registered against the animation renderer once it was loaded. This commit fixes this.

fixes #52076

PR Close #52087
2023-10-10 11:59:13 -07:00
Matthieu Riegler
81e7f5be03 test(animations): update the integration test (#50738)
Let's have the same test app for async and eagerly loaded animations.

PR Close #50738
2023-09-29 10:49:41 -07:00
Matthieu Riegler
e753278faa feat(animations): Add the possibility of lazy loading animations code. (#50738)
`provideLazyLoadedAnimations()` returns providers which allow the lazy loading of the animation module.

Lazy loading of the animation code can shave off up to 16KB gzipped of the main bundle.

PR Close #50738
2023-09-29 10:49:39 -07:00
Jessica Janiuk
ac1afd8649 refactor: relocate animation renderer class for private exports (#51910)
this is a pre-emptive move of the animation renderer to prepare for #50738 to land safely.

PR Close #51910
2023-09-26 15:23:15 -07:00
Matthieu Riegler
0598613950 refactor(animations): deprecation of AnimationDriver.NOOP (#51843)
The `NoopAnimationDriver` as static property of `AnimationDriver` prevents it from being removed by tree shaking. This commit deprecates it and exposes the `NoopAnimationDriver` on the public API to replace its usage.

DEPRECATED:
The `AnimationDriver.NOOP` symbol is deprecated, use `NoopAnimationDriver` instead.

PR Close #51843
2023-09-22 12:15:45 -07:00
Matthieu Riegler
e5d327d049 refactor(animations): Use the Writable type when overwriting readonly properties. (#49754)
The `Writable` type is usefull when we want overwrite readonly properties and we still want to maintain code navigation/reference. It should be use instead of  type assertions.

PR Close #49754
2023-09-22 10:02:14 -07:00
Matthieu Riegler
a1bad49703 refactor(animations): cleanup ahead of animation lazy loading (#51249)
There are no functional changes.

PR Close #51249
2023-08-31 18:35:48 +00:00
Matthieu Riegler
10bab47b4f refactor(animations): remove unecessary interface (#50662)
`Animation` is provided by `lib.dom`.

PR Close #50662
2023-08-07 09:26:22 -07:00
Matthieu Riegler
a14bdfe859 fix(animations): Ensure elements are removed from the cache after leave animation. (#50929)
This commit fixes a memory leak.

`_namespaceLookup` was cleared before the call to `processLeaveNode()` which was using the lookup.
Without that lookup `clearElementCache()` wasn't called thus keeping a reference to the element.

Fixes #24197 & #50533

PR Close #50929
2023-07-11 08:28:10 -07:00
Alan Agius
29f6912e95 refactor(animations): remove redundant castings (#50860)
This commit removes unnecessary castings.

PR Close #50860
2023-06-27 06:27:15 -07:00
Alan Agius
0380564f85 fix(platform-browser): wait until animation completion before destroying renderer (#50860)
Prior to this commit, the renderer destroy method was being called before the animation complete. This is problematic when using `REMOVE_STYLES_ON_COMPONENT_DESTROY` as it causes the styles to be removed too early.

This commit, updates this destroy logic to be call the render destroy once the animations complete.

This has been reported internally in:
- http://b/271251353#comment12
- http://b/282004950#comment5

PR Close #50860
2023-06-27 06:27:15 -07:00
Andrew Kushnir
452a3e9ca0 Revert "fix(platform-browser): wait until animation completion before destroying renderer (#50677)" (#50857)
This reverts commit 2b55103e94.

PR Close #50857
2023-06-26 12:18:39 -07:00
Andrew Kushnir
ed8b088de2 Revert "refactor(animations): remove redundant castings (#50677)" (#50857)
This reverts commit d22734766b.

PR Close #50857
2023-06-26 12:18:38 -07:00
Alan Agius
d22734766b refactor(animations): remove redundant castings (#50677)
This commit removes unnecessary castings.

PR Close #50677
2023-06-26 09:02:42 -07:00
Alan Agius
2b55103e94 fix(platform-browser): wait until animation completion before destroying renderer (#50677)
Prior to this commit, the renderer destroy method was being called before the animation complete. This is problematic when using `REMOVE_STYLES_ON_COMPONENT_DESTROY` as it causes the styles to be removed too early.

This commit, updates this destroy logic to be call the render destroy once the animations complete.

This has been reported internally in:
- http://b/271251353#comment12
- http://b/282004950#comment5

PR Close #50677
2023-06-26 09:02:42 -07:00
Matthieu Riegler
bada9199f5 fix(animations): Trigger leave animation when ViewContainerRef is injected (#48705)
Injecting `ViewContainerRef` into a component makes it effectively a container. The leave animation wasn't triggered on containers before this fix.

fixes angular#48667

PR Close #48705
2023-05-25 14:40:34 -04:00
gdarnell
d0a5530f77 refactor: remove unnecessary array copying (#50370)
Removes `Array.from` and spread operators that have no functional effect.

PR Close #50370
2023-05-22 14:47:29 +00:00
Matthieu Riegler
ec968a99d5 refactor(animations): remove circular deps (#50049)
`AnimationDriver` was not used in shared.ts.

PR Close #50049
2023-05-04 08:58:25 +02:00
Matthieu Riegler
40ed152d21 refactor(animations): remove #9100 todos. (#49407)
Breaking change: On `AnimationPlayer.setPosition` the argument is now of type `number`

PR Close #49407
2023-04-05 19:33:52 -07:00
Alan Agius
d37e21c582 refactor(animations): remove Domino specific logic (#49630)
These workarounds are no longer required following the fixes in https://github.com/angular/domino/pull/14/

PR Close #49630
2023-04-05 11:42:57 -07:00
Matthieu Riegler
477237aa85 refactor(animations): handle #24571 todos (#49231)
This commit removes the remaining ones in animations code base

PR Close #49231
2023-03-06 18:45:33 +00:00
dario-piotrowicz
b3c20add72 Revert "fix(animations): enable shadowElements to leave when their parent does (#46459)" (#46739)
This reverts commit b417370383.

The change applied is no longer appropriate since the use of animations
and shadow dom components is discouraged (as of #46738)

PR Close #46739
2022-07-07 13:51:30 -07:00
dario-piotrowicz
b417370383 fix(animations): enable shadowElements to leave when their parent does (#46459)
when a component uses the shadowDom view encapsulation its children are
not rendered as normal HTML children of the element but they are
insterted in the element's shadowRoot, this causes the leave of the
element not to be normally propagated to the shadow child elements, fix
such issue

resolves #46450

PR Close #46459
2022-06-23 13:49:12 -07:00