Skip to content

Commit 83a992f

Browse files
committed
Merge pull request #12 from brewster1134/2.0.0_animation_refactor
2.0.0_animation_refactor
2 parents e3d22d5 + b37ac5a commit 83a992f

File tree

14 files changed

+227
-257
lines changed

14 files changed

+227
-257
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#### CHANGE LOG
22

3+
###### 2.0.0
4+
* new css api (now requires reverse class css for optional reverse support)
5+
* optimized animations
6+
* hardware-accelerated css animations
7+
* removed confusing reverse class convention
8+
39
###### 1.0.4
410
* allow passing a boolean for `goTo` method's animation argument
511

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
Define several `.tiler-tile` elements inside a single `.tiler-viewport` element.
1212
* `tiler-animation` is the class that will be toggled to allow CSS animations or styles.
13-
* If you use custom reverse styles, you need to signify that to tiler by appeneding a `<` to the class name __(example below)__
1413

1514
_Do __NOT__ add any additional classes to the `tiler-tile` elements. They __WILL__ be overwritten._
1615

@@ -19,10 +18,6 @@ _Do __NOT__ add any additional classes to the `tiler-tile` elements. They __WIL
1918
<div class="tiler-viewport">
2019
<div class="tiler-tile" data-tiler-animation="slide-horizontal" id="tile-1"></div>
2120
<div class="tiler-tile" data-tiler-animation="slide-vertical" id="tile-2"></div>
22-
23-
<!-- note the `less-than` sign in the animation name -->
24-
<!-- that means this animation has a custom reverse defined -->
25-
<div class="tiler-tile" data-tiler-animation="fade<" id="tile-2"></div>
2621
</div>
2722
```
2823

@@ -55,7 +50,7 @@ Tiler animations can be easily defined with a simple convention in your CSS.
5550
* `start` the beginning state of a CSS animation
5651
* This property is treated like a reset. If you use multiple animations, you need to make sure this property will reset ALL styles a given tile may be involved with. For example if you animate using `top`, but you are defining a new animation that animates with `left`, you still need to set `top` to `0` in case it was set to something else from a _different_ animation. __<sup>example below -1-</sup>__
5752
* `end` the end state of a CSS animation
58-
* `reverse` tiler can automatically reverse animations by switching using `start` as the `end` state, and vice-versa. If you need to customize the reverse, you can nest additional animations under a `reverse` class. __<sup>example below -2-</sup>__
53+
* `reverse` If you need to customize the reverse animation, you can nest additional animations under a `reverse` class. __<sup>example below -2-</sup>__
5954
* Only define `transition-property` on the specific animations, and only for the specific attributes you are animating. __<sup>example below -3-</sup>__
6055

6156
```sass
@@ -86,6 +81,19 @@ Tiler animations can be easily defined with a simple convention in your CSS.
8681
&.end
8782
left: -100%
8883
84+
// -2- reverse styles
85+
&.reverse
86+
&.enter
87+
&.start
88+
left: -100%
89+
&.end
90+
left: 0%
91+
&.exit
92+
&.start
93+
left: 0%
94+
&.end
95+
left: 100%
96+
8997
// slide up (slide in from the bottom)
9098
&.slide-vertical
9199
@@ -125,19 +133,6 @@ Tiler animations can be easily defined with a simple convention in your CSS.
125133
opacity: 1
126134
&.end
127135
opacity: 1
128-
129-
// -2- reverse styles for when using the `<` convention (e.g. `fade<`)
130-
&.reverse
131-
&.enter
132-
&.start
133-
opacity: 1
134-
&.end
135-
opacity: 1
136-
&.exit
137-
&.start
138-
opacity: 1
139-
&.end
140-
opacity: 0
141136
```
142137

143138
### Methods

demo/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,51 @@ <h4>Background</h4>
2424
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4"></div>
2525
</div>
2626

27-
<div class="tiler-viewport" id="slide-horizontal">
27+
<div class="tiler-viewport" id="slide-horizontal" data-tiler-animation="slide-horizontal">
2828
<div class="buttons">
2929
<h4>Slide</h4>
3030
<button data-tiler-link="tile-1"></button>
3131
<button data-tiler-link="tile-2"></button>
3232
<button data-tiler-link="tile-3"></button>
3333
<button data-tiler-link="tile-4"></button>
3434
</div>
35-
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1" data-tiler-animation="slide-horizontal">
35+
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1">
3636
<span id="box-1"></span><span id="box-2"></span><span id="box-3"></span>
3737
</div>
38-
<div class="tiler-tile" id="tile-2" data-tiler-title="Tile 2" data-tiler-animation="slide-vertical"></div>
39-
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3" data-tiler-animation="slide-horizontal"></div>
40-
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4" data-tiler-animation="slide-vertical"></div>
38+
<div class="tiler-tile" id="tile-2" data-tiler-title="Tile 2"></div>
39+
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3"></div>
40+
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4"></div>
4141
</div>
4242

43-
<div class="tiler-viewport" id="fade">
43+
<div class="tiler-viewport" id="fade" data-tiler-animation="fade">
4444
<div class="buttons">
4545
<h4>Fade</h4>
4646
<button data-tiler-link="tile-1"></button>
4747
<button data-tiler-link="tile-2"></button>
4848
<button data-tiler-link="tile-3"></button>
4949
<button data-tiler-link="tile-4"></button>
5050
</div>
51-
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1" data-tiler-animation="fade<">
51+
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1">
5252
<span id="box-1"></span><span id="box-2"></span><span id="box-3"></span>
5353
</div>
54-
<div class="tiler-tile" id="tile-2" data-tiler-title="Tile 2" data-tiler-animation="fade<"></div>
55-
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3" data-tiler-animation="fade<"></div>
56-
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4" data-tiler-animation="fade<"></div>
54+
<div class="tiler-tile" id="tile-2" data-tiler-title="Tile 2"></div>
55+
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3"></div>
56+
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4"></div>
5757
</div>
5858

59-
<div class="tiler-viewport" id="slide-vertical">
59+
<div class="tiler-viewport" id="mixed">
6060
<div class="buttons">
6161
<h4>Mixed</h4>
6262
<button data-tiler-link="tile-1"></button>
6363
<button data-tiler-link="tile-2"></button>
6464
<button data-tiler-link="tile-3"></button>
6565
<button data-tiler-link="tile-4"></button>
6666
</div>
67-
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1" data-tiler-animation="fade<">
67+
<div class="tiler-tile" id="tile-1" data-tiler-title="Tile 1" data-tiler-animation="fade">
6868
<span id="box-1"></span><span id="box-2"></span><span id="box-3"></span>
6969
</div>
7070
<div class="tiler-tile" id="tile-2" data-tiler-title="Tile 2" data-tiler-animation="slide-vertical"></div>
71-
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3" data-tiler-animation="fade<"></div>
71+
<div class="tiler-tile" id="tile-3" data-tiler-title="Tile 3" data-tiler-animation="fade"></div>
7272
<div class="tiler-tile" id="tile-4" data-tiler-title="Tile 4" data-tiler-animation="slide-horizontal"></div>
7373
</div>
7474
</body>

demo/tiler_demo.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ html, body {
1616
background-position: 0% 100%;
1717
background-size: auto; }
1818
.tiler-viewport#background .tiler-tile {
19-
background: transparent !important; }
19+
background: transparent; }
2020
.tiler-viewport .buttons {
2121
position: absolute;
2222
z-index: 3;
2323
right: 0;
2424
top: 0; }
2525
.tiler-viewport .tiler-tile {
26-
background-position: center;
27-
transition-duration: 0.25s !important; }
26+
background-position: center; }
2827
.tiler-viewport .tiler-tile#tile-1 {
2928
background-image: url(mountain.jpg); }
3029
.tiler-viewport .tiler-tile#tile-2 {

demo/tiler_demo.sass

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ html, body
1717
background-position: 0% 100%
1818
background-size: auto
1919
.tiler-tile
20-
background: transparent !important
20+
background: transparent
2121

2222
.buttons
2323
position: absolute
@@ -27,7 +27,6 @@ html, body
2727

2828
.tiler-tile
2929
background-position: center
30-
transition-duration: 0.25s !important
3130
&#tile-1
3231
background-image: url(mountain.jpg)
3332
&#tile-2

lib/tiler-animations.css

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.tiler-tile {
2-
transition-timing-function: linear; }
2+
transition-timing-function: linear;
3+
transition-duration: 0.25s; }
34
.tiler-tile.slide-horizontal {
45
transition-property: left;
56
top: 0; }
@@ -11,6 +12,14 @@
1112
left: 0%; }
1213
.tiler-tile.slide-horizontal.exit.end {
1314
left: -100%; }
15+
.tiler-tile.slide-horizontal.reverse.enter.start {
16+
left: -100%; }
17+
.tiler-tile.slide-horizontal.reverse.enter.end {
18+
left: 0%; }
19+
.tiler-tile.slide-horizontal.reverse.exit.start {
20+
left: 0%; }
21+
.tiler-tile.slide-horizontal.reverse.exit.end {
22+
left: 100%; }
1423
.tiler-tile.slide-vertical {
1524
transition-property: top;
1625
left: 0; }
@@ -22,6 +31,14 @@
2231
top: 0%; }
2332
.tiler-tile.slide-vertical.exit.end {
2433
top: -100%; }
34+
.tiler-tile.slide-vertical.reverse.enter.start {
35+
top: -100%; }
36+
.tiler-tile.slide-vertical.reverse.enter.end {
37+
top: 0%; }
38+
.tiler-tile.slide-vertical.reverse.exit.start {
39+
top: 0%; }
40+
.tiler-tile.slide-vertical.reverse.exit.end {
41+
top: 100%; }
2542
.tiler-tile.fade {
2643
transition-property: opacity;
2744
top: 0;
@@ -34,11 +51,3 @@
3451
opacity: 1; }
3552
.tiler-tile.fade.exit.end {
3653
opacity: 1; }
37-
.tiler-tile.fade.reverse.enter.start {
38-
opacity: 1; }
39-
.tiler-tile.fade.reverse.enter.end {
40-
opacity: 1; }
41-
.tiler-tile.fade.reverse.exit.start {
42-
opacity: 1; }
43-
.tiler-tile.fade.reverse.exit.end {
44-
opacity: 0; }

lib/tiler.css

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@
22
position: relative;
33
background: white;
44
overflow: hidden; }
5+
.tiler-viewport.animation-disabled .tiler-tile {
6+
-webkit-transition: none !important;
7+
-moz-transition: none !important;
8+
-o-transition: none !important;
9+
transition: none !important; }
510
.tiler-viewport .tiler-tile {
611
-webkit-transform: translate3d(0, 0, 0);
12+
-moz-transform: translate3d(0, 0, 0);
13+
-ms-transform: translate3d(0, 0, 0);
714
transform: translate3d(0, 0, 0);
815
-webkit-backface-visibility: hidden;
16+
-moz-backface-visibility: hidden;
17+
-ms-backface-visibility: hidden;
918
backface-visibility: hidden;
1019
-webkit-perspective: 1000;
20+
-moz-perspective: 1000;
21+
-ms-perspective: 1000;
1122
perspective: 1000;
12-
transition-duration: 0.25s;
1323
position: absolute;
1424
overflow: hidden;
1525
display: block;
16-
width: 100%;
17-
z-index: -1; }
18-
.tiler-viewport .tiler-tile.enter {
26+
z-index: -1;
27+
width: 100%; }
28+
.tiler-viewport .tiler-tile.active {
1929
z-index: 2; }
20-
.tiler-viewport .tiler-tile.exit {
30+
.tiler-viewport .tiler-tile.previous {
2131
z-index: 1; }

0 commit comments

Comments
 (0)