Skip to content

Commit a8e517a

Browse files
author
lsimone
committed
Documentation for Section Animations
1 parent 4d00feb commit a8e517a

5 files changed

Lines changed: 197 additions & 1 deletion

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{Template {
2+
$classpath: "samples.templates.refresh.animate.AnimatedRefresh",
3+
$hasScript: true,
4+
$css: ["samples.templates.refresh.animate.RefreshCSS"]
5+
}}
6+
7+
{macro main()}
8+
9+
10+
{@aria:Button {
11+
id : "first",
12+
label : "Change data with animation",
13+
onclick : "changeAnimating"
14+
} /}
15+
16+
{@aria:Button {
17+
id : "second",
18+
label : "Change data without animation",
19+
onclick : "changeNotAnimating"
20+
} /}
21+
22+
{@aria:Button {
23+
id : "third",
24+
label : "Manual Refresh",
25+
onclick : "manualRefresh"
26+
} /}
27+
28+
{@aria:Button {
29+
id : "fourth",
30+
label : "Change animation",
31+
onclick : "changeAnimation"
32+
} /}
33+
34+
{section {
35+
id : "autoSection2",
36+
macro : "myMacro2",
37+
cssClass : "page text-center2",
38+
bindRefreshTo : [{
39+
inside : data,
40+
to : "test",
41+
recursive : true
42+
},{
43+
inside : data,
44+
to : "test2",
45+
recursive : true,
46+
animate : false
47+
},{
48+
inside : data.animation,
49+
to : "animateIn",
50+
recursive : true,
51+
animate : false
52+
}],
53+
bind : {
54+
animation : {
55+
to : "animation",
56+
inside : data
57+
}
58+
},
59+
type : "div"
60+
}/}
61+
62+
<div class="log" id="log" > REFRESH LOG: </div>
63+
64+
{/macro}
65+
66+
67+
{macro myMacro2 ()}
68+
<h1>ANIMATING THIS SECTION using <b>${data.animation.animateIn}</b></h1>
69+
<p><i>test</i> is bound to an animated refresh</p>
70+
<p><i>test2</i> is bound to a not animated refresh</p>
71+
<h2>test = ${data.test}</h2>
72+
<h2>test2 = ${data.test2}</h2>
73+
{/macro}
74+
75+
{/Template}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Aria.tplScriptDefinition({
2+
$classpath : 'samples.templates.refresh.animate.AnimatedRefreshScript',
3+
$prototype : {
4+
$dataReady : function () {
5+
6+
this.data = {
7+
test : 0,
8+
test2 : 0,
9+
animation : {
10+
animateOut : "slide left",
11+
animateIn : "slide left"
12+
}
13+
};
14+
15+
},
16+
17+
$afterRefresh : function () {
18+
var log = Aria.$window.document.getElementById("log");
19+
log.innerHTML += "<p>" + "$afterRefresh" + "</p>";
20+
},
21+
22+
$onRefreshAnimationEnd : function () {
23+
var log = Aria.$window.document.getElementById("log");
24+
log.innerHTML += "<p>" + "$onRefreshAnimationEnd" + "</p>";
25+
},
26+
27+
changeAnimating : function (evt) {
28+
aria.utils.Json.setValue(this.data, "test", this.data.test + 1);
29+
},
30+
31+
changeNotAnimating : function (evt) {
32+
aria.utils.Json.setValue(this.data, "test2", this.data.test2 + 1);
33+
},
34+
35+
manualRefresh : function (evt) {
36+
this.data.test = -1;
37+
this.$refresh({
38+
section : "autoSection2",
39+
animate : false
40+
});
41+
},
42+
43+
changeAnimation : function (evt) {
44+
var newAnim = (this.data.animation.animateIn == "slide left") ? "fade" : "slide left";
45+
aria.utils.Json.setValue(this.data.animation, "animateIn", newAnim);
46+
}
47+
}
48+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{CSSTemplate {
2+
$classpath : "samples.templates.refresh.animate.RefreshCSS"
3+
}}
4+
5+
{macro main ()}
6+
7+
.page {
8+
position: absolute;
9+
border: 1px solid red;
10+
padding: 10px;
11+
}
12+
13+
.log {
14+
top: 200px;
15+
position: absolute;
16+
}
17+
18+
{/macro}
19+
20+
{/CSSTemplate}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
title: Animated Refresh
2+
template: samples.templates.refresh.animate.AnimatedRefresh
3+
description: It shows how the Animated Refresh works in aria templates.
4+
sources:
5+
- AnimatedRefresh.tpl
6+
- AnimatedRefreshScript.js
7+
- RefreshCSS.tpl.css
8+
data:
9+
teams:
10+
- name: 'England'
11+
score: 0
12+
- name: 'France'
13+
score: 0
14+
15+
categories: Templates/Refresh

snippets/templates/refresh/Refresh.tpl

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,48 @@
3131
}/}
3232
////#sectionDefTwo
3333

34+
////#sectionDefThree
35+
{section {
36+
id : "autoSection2",
37+
macro : "mySectionMacro",
38+
bindRefreshTo : [{
39+
inside : data.myContainer,
40+
to : "myFirstValue",
41+
recursive : true
42+
},{
43+
inside : data.myContainer,
44+
to : "mySecondValue",
45+
recursive : true,
46+
animate : false
47+
}],
48+
bind : {
49+
animation : {
50+
to : "animation",
51+
inside : data
52+
}
53+
},
54+
type : "div"
55+
}/}
56+
////#sectionDefThree
57+
58+
////#sectionDefFour
59+
data.myContainer.animation = {
60+
animateOut : "slide left",
61+
animateIn : "slide left"
62+
}
63+
////#sectionDefFour
64+
65+
////#sectionDefFive
66+
this.$refresh({
67+
section : "autoSection2",
68+
animate : false
69+
});
70+
////#sectionDefFive
71+
3472
{/macro}
3573

3674
{macro mySectionMacro()}
3775
{/macro}
3876

3977

40-
{/Template}
78+
{/Template}

0 commit comments

Comments
 (0)