Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 201061a

Browse files
authored
Merge pull request #1773 from NativeScript/css_animation_w_h
fix: change example position
2 parents 6beb4b4 + 0c46d15 commit 201061a

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

docs/ui/animation-css.md

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -262,48 +262,9 @@ __Example 13: How to trigger animation on element special state__
262262

263263
> As of version 2.0, only the **Button** component has a built-in special state "highlighted" to indicate that it is touched by the user.
264264
265-
## Access CSS animations from code
266-
267-
The simplest way to trigger a CSS animation is by changing the element **className** property:
268-
269-
__Example 14: How to trigger CSS animation__
270-
271-
```JavaScript
272-
var view = page.getViewById("view");
273-
view.className = "transparent";
274-
```
275-
```TypeScript
276-
let view = page.getViewById<viewModule.View>("view");
277-
view.className = "transparent";
278-
```
279-
280-
All keyframes defined in CSS can be accessed with code by using the **getKeyframeAnimationWithName** method. This allows further customization of animation properties:
265+
## Animations - width and height
281266

282-
__Example 15: Accessing CSS defined keyframe in the code via **getKeyframeAnimationWithName** method__
283-
284-
``` JavaScript
285-
var keyframeAnimation = require("tns-core-modules/ui/animation/keyframe-animation");
286-
287-
var view = page.getViewById("view");
288-
var animationInfo = page.getKeyframeAnimationWithName("bounce");
289-
animationInfo.duration = 2000;
290-
var animation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);
291-
animation.play(view).then(() => {
292-
console.log("Played with code!");
293-
});
294-
```
295-
``` TypeScript
296-
import {KeyframeAnimation} from "tns-core-modules/ui/animation/keyframe-animation";
297-
298-
let view = page.getViewById<viewModule.View>("view");
299-
let animationInfo = page.getKeyframeAnimationWithName("bounce");
300-
animationInfo.duration = 2000;
301-
let animation = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);
302-
animation.play(view).then(() => {
303-
console.log("Played with code!");
304-
});
305-
```
306-
__Example 1: How to animate view's width and height.__
267+
__Example 14: How to animate view's width and height.__
307268
{% nativescript %}
308269
```XML
309270
<GridLayout rows="* *" columns="*" class="home-panel">
@@ -375,4 +336,47 @@ __Example 1: How to animate view's width and height.__
375336
}
376337
```
377338
[Demo](https://play.nativescript.org/?template=play-ng&id=NMM4I5)
378-
{% endangular %}
339+
{% endangular %}
340+
341+
## Access CSS animations from code
342+
343+
The simplest way to trigger a CSS animation is by changing the element **className** property:
344+
345+
__Example 15: How to trigger CSS animation__
346+
347+
```JavaScript
348+
var view = page.getViewById("view");
349+
view.className = "transparent";
350+
```
351+
```TypeScript
352+
let view = page.getViewById<viewModule.View>("view");
353+
view.className = "transparent";
354+
```
355+
356+
All keyframes defined in CSS can be accessed with code by using the **getKeyframeAnimationWithName** method. This allows further customization of animation properties:
357+
358+
359+
__Example 16: Accessing CSS defined keyframe in the code via **getKeyframeAnimationWithName** method__
360+
361+
``` JavaScript
362+
var keyframeAnimation = require("tns-core-modules/ui/animation/keyframe-animation");
363+
364+
var view = page.getViewById("view");
365+
var animationInfo = page.getKeyframeAnimationWithName("bounce");
366+
animationInfo.duration = 2000;
367+
var animation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);
368+
animation.play(view).then(() => {
369+
console.log("Played with code!");
370+
});
371+
```
372+
``` TypeScript
373+
import {KeyframeAnimation} from "tns-core-modules/ui/animation/keyframe-animation";
374+
375+
let view = page.getViewById<viewModule.View>("view");
376+
let animationInfo = page.getKeyframeAnimationWithName("bounce");
377+
animationInfo.duration = 2000;
378+
let animation = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);
379+
animation.play(view).then(() => {
380+
console.log("Played with code!");
381+
});
382+
```

0 commit comments

Comments
 (0)