Skip to content

Commit 583aa11

Browse files
committed
[refactor] improve header menu control
1 parent 6a87114 commit 583aa11

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

‎js/control.js‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,6 @@ var control = (function(){
509509
returnvalue/100;
510510
}
511511
};
512-
// var toggleValue = function(object){
513-
// var value = false;
514-
// if (helper.getObject({
515-
// object: state.get(),
516-
// path: object.path
517-
// })){
518-
// value = true;
519-
// };
520-
// helper.setObject({
521-
// path: object.path,
522-
// object: state.get(),
523-
// newValue: value
524-
// });
525-
// };
526512
varchangeValue=function(object){
527513
if(object.path){
528514
varnewValue=valueType[object.type](object);
@@ -554,7 +540,6 @@ var control = (function(){
554540
if(object.func){
555541
object.func();
556542
};
557-
// toggleValue(object);
558543
}
559544
};
560545
object.element.addEventListener(eventType[object.type],function(){

‎js/menu.js‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,38 @@ var menu = (function(){
3535
};
3636

3737
varclose=function(){
38-
state.get().menu=false;
38+
helper.setObject({
39+
object: state.get(),
40+
path: "menu",
41+
newValue: false
42+
});
3943
render();
4044
};
4145

4246
varopen=function(){
4347
_scrollToTop(helper.e(".menu-content"));
44-
state.get().menu=true;
48+
helper.setObject({
49+
object: state.get(),
50+
path: "menu",
51+
newValue: true
52+
});
4553
render();
4654
};
4755

4856
vartoggle=function(){
4957
if(state.get().menu){
50-
state.get().menu=false;
58+
helper.setObject({
59+
object: state.get(),
60+
path: "menu",
61+
newValue: false
62+
});
5163
}else{
5264
_scrollToTop(helper.e(".menu-content"));
53-
state.get().menu=true;
65+
helper.setObject({
66+
object: state.get(),
67+
path: "menu",
68+
newValue: true
69+
});
5470
};
5571
render();
5672
};

0 commit comments

Comments
(0)