Skip to content

Commit 24614be

Browse files
author
Anatoly Ostrovsky
committed
Remove .enabled
1 parent 0fd2f9c commit 24614be

File tree

5 files changed

+84
-65
lines changed

5 files changed

+84
-65
lines changed

@types/animations/animate-queue.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export class AnimateQueueProvider {
1919
off(event: any, container: any, callback: any, ...args: any[]): void;
2020
pin(element: any, parentElement: any): void;
2121
push(element: any, event: any, options: any, domOperation: any): any;
22-
enabled(element: any, bool: any, ...args: any[]): any;
2322
})
2423
)[];
2524
}

src/animations/animate-legacy.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>AngularTS Test Runner</title>
6+
7+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8+
<script
9+
src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.3/angular.min.js"
10+
integrity="sha512-KZmyTq3PLx9EZl0RHShHQuXtrvdJ+m35tuOiwlcZfs/rE7NZv29ygNA8SFCkMXTnYZQK2OX0Gm2qKGfvWEtRXA=="
11+
crossorigin="anonymous"
12+
referrerpolicy="no-referrer"
13+
></script>
14+
<script
15+
src="https://cdnjs.cloudflare.com/ajax/libs/angular-animate/1.8.3/angular-animate.min.js"
16+
integrity="sha512-Vhup4/4s+jnmiFsp1Sg1/6jXncRbIBc+fKemYjq1n+nEXthmeASyaWnClWsAV5Sas7WbLMLNYYHw6TxwQE4oPQ=="
17+
crossorigin="anonymous"
18+
referrerpolicy="no-referrer"
19+
></script>
20+
<script>
21+
window.angular.module("test", []).directive("test", [
22+
"$animate",
23+
function ($animate) {
24+
return {
25+
compile(e) {
26+
debugger;
27+
$animate.animate(e, { color: "rgb(255, 0, 0)" });
28+
},
29+
};
30+
},
31+
]);
32+
</script>
33+
</head>
34+
<body ng-app="test">
35+
<div test>this box is moody</div>
36+
</body>
37+
</html>

src/animations/animate-queue.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ export function AnimateQueueProvider($animateProvider) {
168168
const disabledElementsLookup = new Map();
169169
let animationsEnabled = null;
170170

171-
function removeFromDisabledElementsLookup(evt) {
172-
disabledElementsLookup.delete(evt.target);
173-
}
174-
175171
function postDigestTaskFactory() {
176172
let postDigestCalled = false;
177173
return function (fn) {
@@ -353,47 +349,6 @@ export function AnimateQueueProvider($animateProvider) {
353349
options.domOperation = domOperation;
354350
return queueAnimation(element, event, options);
355351
},
356-
357-
// this method has four signatures:
358-
// () - global getter
359-
// (bool) - global setter
360-
// (element) - element getter
361-
// (element, bool) - element setter<F37>
362-
enabled(element, bool) {
363-
const argCount = arguments.length;
364-
365-
if (argCount === 0) {
366-
// () - Global getter
367-
bool = !!animationsEnabled;
368-
} else {
369-
const hasElement = isElement(element);
370-
371-
if (!hasElement) {
372-
// (bool) - Global setter
373-
bool = animationsEnabled = !!element;
374-
} else {
375-
const node = element;
376-
377-
if (argCount === 1) {
378-
// (element) - Element getter
379-
bool = !disabledElementsLookup.get(node);
380-
} else {
381-
// (element, bool) - Element setter
382-
if (!disabledElementsLookup.has(node)) {
383-
// The element is added to the map for the first time.
384-
// Create a listener to remove it on `$destroy` (to avoid memory leak).
385-
element.addEventListener(
386-
"$destroy",
387-
removeFromDisabledElementsLookup,
388-
);
389-
}
390-
disabledElementsLookup.set(node, !bool);
391-
}
392-
}
393-
}
394-
395-
return bool;
396-
},
397352
};
398353

399354
return $animate;

src/animations/animate-test.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>AngularTS Test Runner</title>
6+
7+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8+
9+
<!--
10+
<script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.js"></script>
11+
<script src="https://cdn.jsdelivr.net/npm/angular-animate@1.8.3/angular-animate.js"></script>
12+
<script>window.angular.module("test", [])</script> -->
13+
14+
<script type="module" src="/src/index.js"></script>
15+
<script>
16+
document.addEventListener("DOMContentLoaded", () => {
17+
window.angular.module("test", []).directive("test", [
18+
"$animate",
19+
function ($animate) {
20+
return {
21+
compile(e) {
22+
debugger;
23+
$animate.animate(e, { color: "rgb(255, 0, 0)" });
24+
},
25+
};
26+
},
27+
]);
28+
});
29+
</script>
30+
</head>
31+
<body ng-app="test">
32+
<div test>this box is moody</div>
33+
</body>
34+
</html>

src/animations/animate.spec.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,19 @@ describe("$animate", () => {
7373
expect(element.textContent).toBe("21");
7474
});
7575

76-
fit("should apply styles instantly to the element", async () => {
77-
element = $compile(element)($rootScope);
78-
$animate.animate(element, { color: "rgb(0, 0, 0)" });
79-
$rootScope.$flushQueue();
80-
await wait(100);
81-
debugger;
82-
expect(element.style.color).toBe("rgb(0, 0, 0)");
83-
84-
// $animate.animate(
85-
// element,
86-
// { color: "rgb(255, 0, 0)" },
87-
// { color: "rgb(0, 255, 0)" },
88-
// );
89-
// $rootScope.$flushQueue();
90-
// expect(element.style.color).toBe("rgb(0, 255, 0)");
91-
});
92-
93-
it("should still perform DOM operations even if animations are disabled (post-digest)", () => {
94-
$animate.enabled(false);
76+
// it("should apply styles instantly to the element", async () => {
77+
// element = $compile(element)($rootScope);
78+
// $animate.animate(element, { color: "rgb(0, 0, 0)" });
79+
// expect(element.style.color).toBe("rgb(0, 0, 0)");
80+
// $animate.animate(
81+
// element,
82+
// { color: "rgb(255, 0, 0)" },
83+
// { color: "rgb(0, 255, 0)" },
84+
// );
85+
// expect(element.style.color).toBe("rgb(0, 255, 0)");
86+
// });
87+
88+
fit("should still perform DOM operations even if animations are disabled (post-digest)", () => {
9589
expect(element.classList.contains("ng-hide")).toBeFalse();
9690
$animate.addClass(element, "ng-hide");
9791
expect(element.classList.contains("ng-hide")).toBeTrue();

0 commit comments

Comments
 (0)