const makeMenu = function (value, items, memMenuThunk, collapsable) {
return {
value,
dom: {
tag: 'div'
},
components: [
Button.sketch({
dom: {
tag: 'div',
classes: [ Styles.resolve('styles-collapser') ]
},
components: collapsable ? [
{
dom: {
tag: 'span',
classes: [ Styles.resolve('styles-collapse-icon') ]
}
},
GuiFactory.text(value)
] : [ GuiFactory.text(value) ],
action (item) {
if (collapsable) {
const comp = memMenuThunk().get(item);
TieredMenu.collapseMenu(comp);
}
}
}),
{
dom: {
tag: 'div',
classes: [ Styles.resolve('styles-menu-items-container') ]
},
components: [
Menu.parts().items({ })
],
behaviours: Behaviour.derive([
AddEventsBehaviour.config('adhoc-scrollable-menu', [
AlloyEvents.runOnAttached(function (component, simulatedEvent) {
Css.set(component.element(), 'overflow-y', 'auto');
Css.set(component.element(), '-webkit-overflow-scrolling', 'touch');
Scrollable.register(component.element());
}),
AlloyEvents.runOnDetached(function (component) {
Css.remove(component.element(), 'overflow-y');
Css.remove(component.element(), '-webkit-overflow-scrolling');
Scrollable.deregister(component.element());
})
])
])
}
],
items,
menuBehaviours: Behaviour.derive([
Transitioning.config({
initialState: 'after',
routes: Transitioning.createTristate('before', 'current', 'after', {
transition: {
property: 'transform',
transitionClass: 'transitioning'
}
})
})
])
};
};
请发表评论