[refactor] improve header menu control
This commit is contained in:
parent
6a87114499
commit
583aa1131e
|
@ -509,20 +509,6 @@ var control = (function() {
|
|||
return value / 100;
|
||||
}
|
||||
};
|
||||
// var toggleValue = function(object) {
|
||||
// var value = false;
|
||||
// if (helper.getObject({
|
||||
// object: state.get(),
|
||||
// path: object.path
|
||||
// })) {
|
||||
// value = true;
|
||||
// };
|
||||
// helper.setObject({
|
||||
// path: object.path,
|
||||
// object: state.get(),
|
||||
// newValue: value
|
||||
// });
|
||||
// };
|
||||
var changeValue = function(object) {
|
||||
if (object.path) {
|
||||
var newValue = valueType[object.type](object);
|
||||
|
@ -554,7 +540,6 @@ var control = (function() {
|
|||
if (object.func) {
|
||||
object.func();
|
||||
};
|
||||
// toggleValue(object);
|
||||
}
|
||||
};
|
||||
object.element.addEventListener(eventType[object.type], function() {
|
||||
|
|
24
js/menu.js
24
js/menu.js
|
@ -35,22 +35,38 @@ var menu = (function() {
|
|||
};
|
||||
|
||||
var close = function() {
|
||||
state.get().menu = false;
|
||||
helper.setObject({
|
||||
object: state.get(),
|
||||
path: "menu",
|
||||
newValue: false
|
||||
});
|
||||
render();
|
||||
};
|
||||
|
||||
var open = function() {
|
||||
_scrollToTop(helper.e(".menu-content"));
|
||||
state.get().menu = true;
|
||||
helper.setObject({
|
||||
object: state.get(),
|
||||
path: "menu",
|
||||
newValue: true
|
||||
});
|
||||
render();
|
||||
};
|
||||
|
||||
var toggle = function() {
|
||||
if (state.get().menu) {
|
||||
state.get().menu = false;
|
||||
helper.setObject({
|
||||
object: state.get(),
|
||||
path: "menu",
|
||||
newValue: false
|
||||
});
|
||||
} else {
|
||||
_scrollToTop(helper.e(".menu-content"));
|
||||
state.get().menu = true;
|
||||
helper.setObject({
|
||||
object: state.get(),
|
||||
path: "menu",
|
||||
newValue: true
|
||||
});
|
||||
};
|
||||
render();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue