fix: disable transition properties (#2659)

This commit is contained in:
Niklas von Hertzen 2021-08-14 16:22:36 +08:00 committed by GitHub
parent cd0d7258c3
commit f143166551
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View File

@ -143,7 +143,6 @@ export class CSSParsedDeclaration {
textTransform: ReturnType<typeof textTransform.parse>; textTransform: ReturnType<typeof textTransform.parse>;
transform: ReturnType<typeof transform.parse>; transform: ReturnType<typeof transform.parse>;
transformOrigin: ReturnType<typeof transformOrigin.parse>; transformOrigin: ReturnType<typeof transformOrigin.parse>;
transitionDuration: ReturnType<typeof duration.parse>;
visibility: ReturnType<typeof visibility.parse>; visibility: ReturnType<typeof visibility.parse>;
webkitTextStrokeColor: Color; webkitTextStrokeColor: Color;
webkitTextStrokeWidth: ReturnType<typeof webkitTextStrokeWidth.parse>; webkitTextStrokeWidth: ReturnType<typeof webkitTextStrokeWidth.parse>;
@ -221,7 +220,6 @@ export class CSSParsedDeclaration {
this.textTransform = parse(context, textTransform, declaration.textTransform); this.textTransform = parse(context, textTransform, declaration.textTransform);
this.transform = parse(context, transform, declaration.transform); this.transform = parse(context, transform, declaration.transform);
this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin); this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
this.transitionDuration = parse(context, duration, declaration.transitionDuration);
this.visibility = parse(context, visibility, declaration.visibility); this.visibility = parse(context, visibility, declaration.visibility);
this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor); this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth); this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);

View File

@ -233,6 +233,7 @@ export class DocumentCloner {
if (window && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) { if (window && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) {
const clone = this.createElementClone(node); const clone = this.createElementClone(node);
clone.style.transitionProperty = 'none';
const style = window.getComputedStyle(node); const style = window.getComputedStyle(node);
const styleBefore = window.getComputedStyle(node, ':before'); const styleBefore = window.getComputedStyle(node, ':before');

View File

@ -23,15 +23,13 @@ export class ElementContainer {
if (isDebugging(element, DebuggerType.PARSE)) { if (isDebugging(element, DebuggerType.PARSE)) {
debugger; debugger;
} }
this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null)); this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null));
if (isHTMLElementNode(element)) { if (isHTMLElementNode(element)) {
if (this.styles.animationDuration.some((duration) => duration > 0)) { if (this.styles.animationDuration.some((duration) => duration > 0)) {
element.style.animationDuration = '0s'; element.style.animationDuration = '0s';
} }
if (this.styles.transitionDuration.some((duration) => duration > 0)) {
element.style.transitionDuration = '0s';
}
if (this.styles.transform !== null) { if (this.styles.transform !== null) {
// getBoundingClientRect takes transforms into account // getBoundingClientRect takes transforms into account

View File

@ -55,6 +55,11 @@
transform: rotate(45deg) transform: rotate(45deg)
} }
.transition-delay {
transition: 1ms;
transition-delay: 50ms;
transform: rotate(45deg)
}
div { div {
float: left; float: left;
@ -84,5 +89,9 @@
<div class="transitioned broken"> <div class="transitioned broken">
<p>Hello</p> <p>Hello</p>
</div> </div>
<div class="transition-delay">
<p>Hello</p>
</div>
</body> </body>
</html> </html>