Skip to content

Commit 7f5bea4

Browse files
committed
refactor sidebar animation with css
1 parent 7e29ef5 commit 7f5bea4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

public/css/lfm.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ a {
6363
#tree {
6464
position: absolute;
6565
z-index: 999;
66-
left: -300px;
66+
left: 0;
67+
transform: translateX(-100%);
68+
transition: 1s transform;
69+
}
70+
71+
#tree.in {
72+
transform: translateX(0);
6773
}
6874
}
6975

public/js/script.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var show_list;
2-
var show_tree = false;
32
var sort_type = 'alphabetic';
43
var multi_selection_enabled = false;
54
var selected = [];
@@ -137,23 +136,18 @@ $('#to-previous').click(function () {
137136
});
138137

139138
function toggleMobileTree(should_display) {
140-
if (should_display) {
141-
var position = '0px';
142-
} else {
143-
var position = '-' + $('#tree').width() + 'px';
139+
if (should_display === undefined) {
140+
should_display = !$('#tree').hasClass('in');
144141
}
145-
146-
$('#tree').animate({'left': position}, 1000, 'easeOutExpo', function () {
147-
show_tree = should_display;
148-
});
142+
$('#tree').toggleClass('in', should_display);
149143
}
150144

151145
$('#show_tree').click(function (e) {
152-
toggleMobileTree(!show_tree);
146+
toggleMobileTree();
153147
});
154148

155149
$('#main').click(function (e) {
156-
if (show_tree) {
150+
if ($('#tree').hasClass('in')) {
157151
toggleMobileTree(false);
158152
}
159153
});

0 commit comments

Comments
 (0)