| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ import { View } from "../core/view"; | |||
| 12 | 12 | // Types. | |
| 13 | 13 | import { Color } from "../../color"; | |
| 14 | 14 | import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace"; | |
| 15 | + import { PercentLength } from "../styling/style-properties"; | ||
| 15 | 16 | ||
| 16 | 17 | export { Color, traceEnabled, traceWrite, traceCategories, traceType }; | |
| 17 | 18 | ||
@@ -161,22 +162,19 @@ export abstract class AnimationBase implements AnimationBaseDefinition { | |||
| 161 | 162 | continue; | |
| 162 | 163 | } | |
| 163 | 164 | ||
| 164 | - if (item === Properties.opacity || | ||
| 165 | + if ((item === Properties.opacity || | ||
| 165 | 166 | item === "duration" || | |
| 166 | 167 | item === "delay" || | |
| 167 | - item === "iterations") { | ||
| 168 | - | ||
| 169 | - if (typeof value !== "number") { | ||
| 170 | - throw new Error(`Property ${item} must be valid number. Value: ${value}`); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - } else if (item === Properties.scale || item === Properties.translate) { | ||
| 174 | - const pair = <Pair>value; | ||
| 175 | - if (typeof pair.x !== "number" || typeof pair.y !== "number") { | ||
| 176 | - throw new Error(`Property ${item} must be valid Pair. Value: ${value}`); | ||
| 177 | - } | ||
| 168 | + item === "iterations") && typeof value !== "number") { | ||
| 169 | + throw new Error(`Property ${item} must be valid number. Value: ${value}`); | ||
| 170 | + } else if ((item === Properties.scale || item === Properties.translate) && | ||
| 171 | + (typeof (<Pair>value).x !== "number" || typeof (<Pair>value).y !== "number")) { | ||
| 172 | + throw new Error(`Property ${item} must be valid Pair. Value: ${value}`); | ||
| 178 | 173 | } else if (item === Properties.backgroundColor && !Color.isValid(animationDefinition.backgroundColor)) { | |
| 179 | 174 | throw new Error(`Property ${item} must be valid color. Value: ${value}`); | |
| 175 | + } else if (item === Properties.width || item === Properties.height) { | ||
| 176 | + // Coerce input into a PercentLength object in case it's a string. | ||
| 177 | + animationDefinition[item] = PercentLength.parse(<any>value); | ||
| 180 | 178 | } else if (item === Properties.rotate) { | |
| 181 | 179 | const rotate: number | Point3D = value; | |
| 182 | 180 | if ((typeof rotate !== "number") && | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,7 @@ export function test_ReadTransformAllSet() { | |||
| 122 | 122 | const animation = createAnimationFromCSS(css, "test"); | |
| 123 | 123 | const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations); | |
| 124 | 124 | ||
| 125 | - TKUnit.assertAreClose(rotate, 10, DELTA); | ||
| 125 | + TKUnit.assertAreClose(rotate.z, 10, DELTA); | ||
| 126 | 126 | ||
| 127 | 127 | TKUnit.assertAreClose(scale.x, 5, SCALE_DELTA); | |
| 128 | 128 | TKUnit.assertAreClose(scale.y, 1, SCALE_DELTA); | |
@@ -136,7 +136,7 @@ export function test_ReadTransformNone() { | |||
| 136 | 136 | const animation = createAnimationFromCSS(css, "test"); | |
| 137 | 137 | const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations); | |
| 138 | 138 | ||
| 139 | - TKUnit.assertEqual(rotate, 0); | ||
| 139 | + TKUnit.assertEqual(rotate.z, 0); | ||
| 140 | 140 | ||
| 141 | 141 | TKUnit.assertEqual(scale.x, 1); | |
| 142 | 142 | TKUnit.assertEqual(scale.y, 1); | |
@@ -271,7 +271,7 @@ export function test_ReadRotate() { | |||
| 271 | 271 | const { rotate } = getTransforms(animation.keyframes[0].declarations); | |
| 272 | 272 | ||
| 273 | 273 | TKUnit.assertEqual(rotate.property, "rotate"); | |
| 274 | - TKUnit.assertAreClose(rotate.value, 5, DELTA); | ||
| 274 | + TKUnit.assertAreClose(rotate.value.z, 5, DELTA); | ||
| 275 | 275 | } | |
| 276 | 276 | ||
| 277 | 277 | export function test_ReadRotateDeg() { | |
@@ -280,7 +280,7 @@ export function test_ReadRotateDeg() { | |||
| 280 | 280 | const { rotate } = getTransforms(animation.keyframes[0].declarations); | |
| 281 | 281 | ||
| 282 | 282 | TKUnit.assertEqual(rotate.property, "rotate"); | |
| 283 | - TKUnit.assertAreClose(rotate.value, 45, DELTA); | ||
| 283 | + TKUnit.assertAreClose(rotate.value.z, 45, DELTA); | ||
| 284 | 284 | } | |
| 285 | 285 | ||
| 286 | 286 | export function test_ReadRotateRad() { | |
@@ -289,7 +289,7 @@ export function test_ReadRotateRad() { | |||
| 289 | 289 | const { rotate } = getTransforms(animation.keyframes[0].declarations); | |
| 290 | 290 | ||
| 291 | 291 | TKUnit.assertEqual(rotate.property, "rotate"); | |
| 292 | - TKUnit.assertAreClose(rotate.value, 45, DELTA); | ||
| 292 | + TKUnit.assertAreClose(rotate.value.z, 45, DELTA); | ||
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | export function test_ReadAnimationWithUnsortedKeyframes() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments