[refactor] improve header menu control

This commit is contained in:
zombieFox 2019-02-03 14:36:40 +00:00
parent 6a87114499
commit 583aa1131e
2 changed files with 20 additions and 19 deletions

View File

@ -509,20 +509,6 @@ var control = (function() {
return value / 100; 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) { var changeValue = function(object) {
if (object.path) { if (object.path) {
var newValue = valueType[object.type](object); var newValue = valueType[object.type](object);
@ -554,7 +540,6 @@ var control = (function() {
if (object.func) { if (object.func) {
object.func(); object.func();
}; };
// toggleValue(object);
} }
}; };
object.element.addEventListener(eventType[object.type], function() { object.element.addEventListener(eventType[object.type], function() {

View File

@ -35,22 +35,38 @@ var menu = (function() {
}; };
var close = function() { var close = function() {
state.get().menu = false; helper.setObject({
object: state.get(),
path: "menu",
newValue: false
});
render(); render();
}; };
var open = function() { var open = function() {
_scrollToTop(helper.e(".menu-content")); _scrollToTop(helper.e(".menu-content"));
state.get().menu = true; helper.setObject({
object: state.get(),
path: "menu",
newValue: true
});
render(); render();
}; };
var toggle = function() { var toggle = function() {
if (state.get().menu) { if (state.get().menu) {
state.get().menu = false; helper.setObject({
object: state.get(),
path: "menu",
newValue: false
});
} else { } else {
_scrollToTop(helper.e(".menu-content")); _scrollToTop(helper.e(".menu-content"));
state.get().menu = true; helper.setObject({
object: state.get(),
path: "menu",
newValue: true
});
}; };
render(); render();
}; };