Skip to content

Commit 294850b

Browse files
authored
Merge pull request #2 from LukePulverenti/master
update easing
2 parents ba0acc5 + 5bf05a1 commit 294850b

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

sample.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="initial-scale=1">
66
<title>Sample - Touch Menu Like Android</title>
7-
<link rel="stylesheet" href="src/css/touch-tabs-la.min.css">
7+
<link rel="stylesheet" href="src/css/touch-menu-la.css">
88
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>
99
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@@ -48,7 +48,7 @@
4848
</div>
4949

5050
<script src="lib/hammerjs/hammer.min.js"></script>
51-
<script src="src/js/touch-tabs-la.min.js"></script>
51+
<script src="src/js/touch-menu-la.js"></script>
5252
<script>
5353
var TouchMenu = TouchMenuLA({
5454
target: document.getElementById('menu')

src/css/touch-menu-la.css

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
}
1717

1818
.touch-menu-la.opened {
19-
transition: all 0.3s ease !important;
20-
-webkit-transition: all 0.3s ease !important;
21-
-moz-transition: all 0.3s ease !important;
19+
transition: all 0.3s ease-out !important;
20+
-webkit-transition: all 0.3s ease-out !important;
21+
-moz-transition: all 0.3s ease-out !important;
2222
}
2323

2424
.touch-menu-la.closed {
25-
transition: all 0.3s ease !important;
26-
-webkit-transition: all 0.3s ease !important;
27-
-moz-transition: all 0.3s ease !important;
28-
transform: translate3d(0, 0, 0) !important;
29-
-webkit-transform: translate3d(0, 0, 0) !important;
30-
-moz-transform: translate3d(0, 0, 0) !important;
25+
transition: all 0.3s ease-out !important;
26+
-webkit-transition: all 0.3s ease-out !important;
27+
-moz-transition: all 0.3s ease-out !important;
28+
transform: none !important;
29+
-webkit-transform: none !important;
30+
-moz-transform: none !important;
3131
}
3232

3333
.tmla-mask {

src/js/touch-menu-la.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ var TouchMenuLA = function (options) {
6666
});
6767
};
6868

69+
TouchMenuLA.prototype.animateToPosition = function (pos) {
70+
options.target.style.transform = 'translate3d(' + pos + 'px, 0, 0)';
71+
options.target.style.WebkitTransform = 'translate3d(' + pos + 'px, 0, 0)';
72+
options.target.style.MozTransform = 'translate3d(' + pos + 'px, 0, 0)';
73+
74+
};
75+
6976
TouchMenuLA.prototype.changeMenuPos = function () {
7077
if (newPos <= options.width) {
7178
options.target.className = menuClassName + ' tmla-menu';
72-
options.target.style.transform = 'translate3d(' + newPos + 'px, 0, 0)';
73-
options.target.style.WebkitTransform = 'translate3d(' + newPos + 'px, 0, 0)';
74-
options.target.style.MozTransform = 'translate3d(' + newPos + 'px, 0, 0)';
79+
this.animateToPosition(newPos);
7580

7681
if (!options.disableMask) {
7782
this.setMaskOpacity(newPos);
@@ -147,9 +152,7 @@ var TouchMenuLA = function (options) {
147152

148153
TouchMenuLA.prototype.open = function () {
149154
options.target.className = menuClassName + " tmla-menu opened";
150-
options.target.style.transform = 'translate3d(' + options.width + 'px, 0, 0)';
151-
options.target.style.WebkitTransform = 'translate3d(' + options.width + 'px, 0, 0)';
152-
options.target.style.MozTransform = 'translate3d(' + options.width + 'px, 0, 0)';
155+
this.animateToPosition(options.width);
153156

154157
currentPos = options.width;
155158
this.isVisible = true;

0 commit comments

Comments
 (0)