Skip to content

Commit e91104f

Browse files
committed
button.Base: register menus to the ScrollSync main thread addon #4579
1 parent 43e7c18 commit e91104f

4 files changed

Lines changed: 65 additions & 34 deletions

File tree

examples/ConfigurationViewport.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class ConfigurationViewport extends Viewport {
4949
/**
5050
* @member {Number} exampleComponentFlex=1
5151
*/
52-
exampleComponentFlex: 2
52+
exampleComponentFlex: 2,
53+
/**
54+
* @member {Number} exampleContainerConfig=null
55+
*/
56+
exampleContainerConfig: null
5357
}
5458

5559
/**
@@ -69,7 +73,8 @@ class ConfigurationViewport extends Viewport {
6973
items : [me.exampleComponent],
7074
flex : me.exampleComponentFlex,
7175
layout: 'base',
72-
style : {padding: '20px'}
76+
style : {padding: '20px'},
77+
...me.exampleContainerConfig
7378
}, {
7479
module: Panel,
7580
cls : ['neo-panel', 'neo-container', 'neo-configuration-panel'],

examples/button/base/MainContainer.mjs

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Button from '../../../src/button/Base.mjs';
22
import CheckBox from '../../../src/form/field/CheckBox.mjs';
33
import ConfigurationViewport from '../../ConfigurationViewport.mjs';
4+
import Container from '../../../src/container/Base.mjs';
45
import NumberField from '../../../src/form/field/Number.mjs';
56
import Radio from '../../../src/form/field/Radio.mjs';
67
import SelectField from '../../../src/form/field/Select.mjs';
@@ -15,7 +16,14 @@ class MainContainer extends ConfigurationViewport {
1516
className : 'Neo.examples.button.base.MainContainer',
1617
configItemLabelWidth: 160,
1718
configItemWidth : 280,
18-
layout : {ntype: 'hbox', align: 'stretch'}
19+
layout : {ntype: 'hbox', align: 'stretch'},
20+
21+
exampleContainerConfig: {
22+
style: {
23+
overflow: 'auto',
24+
padding : '20px'
25+
}
26+
}
1927
}
2028

2129
createConfigurationComponents() {
@@ -175,32 +183,39 @@ class MainContainer extends ConfigurationViewport {
175183
*/
176184
createExampleComponent() {
177185
return Neo.create({
178-
module : Button,
179-
badgeText: 'Badge',
180-
handler : data => console.log('button click =>', data.component.id),
181-
height : 50,
182-
iconCls : 'fa fa-home',
183-
text : 'Hello World',
184-
ui : 'primary',
185-
width : 150,
186+
module: Container,
187+
height: 2000,
188+
layout: 'vbox',
186189

187-
menu: [{
188-
handler: data => console.log('menu item 1 click =>', data),
189-
iconCls: 'fa fa-home',
190-
text : 'Item 1'
191-
}, {
192-
handler: data => console.log('menu item 2 click =>', data),
193-
iconCls: 'fa fa-user',
194-
text : 'Item 2'
195-
}, {
196-
handler: data => console.log('menu item 3 click =>', data),
197-
iconCls: 'fa fa-play',
198-
text : 'Item 3'
199-
}]
190+
items: [{
191+
module : Button,
192+
badgeText: 'Badge',
193+
handler : data => console.log('button click =>', data.component.id),
194+
height : 50,
195+
iconCls : 'fa fa-home',
196+
style : {marginTop: '500px'},
197+
text : 'Hello World',
198+
ui : 'primary',
199+
width : 150,
200200

201-
/*tooltips: [{
202-
text: 'Hello World Tooltip'
203-
}]*/
201+
menu: [{
202+
handler: data => console.log('menu item 1 click =>', data),
203+
iconCls: 'fa fa-home',
204+
text : 'Item 1'
205+
}, {
206+
handler: data => console.log('menu item 2 click =>', data),
207+
iconCls: 'fa fa-user',
208+
text : 'Item 2'
209+
}, {
210+
handler: data => console.log('menu item 3 click =>', data),
211+
iconCls: 'fa fa-play',
212+
text : 'Item 3'
213+
}]
214+
215+
/*tooltips: [{
216+
text: 'Hello World Tooltip'
217+
}]*/
218+
}]
204219
})
205220
}
206221
}

src/button/Base.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,13 @@ class Base extends Component {
251251
let me = this;
252252

253253
me.menuList = Neo.create({
254-
module : module.default,
255-
appName : me.appName,
256-
displayField: 'text',
257-
floating : true,
258-
hidden : true,
259-
items : value
254+
module : module.default,
255+
appName : me.appName,
256+
displayField : 'text',
257+
floating : true,
258+
hidden : true,
259+
items : value,
260+
parentComponent: me
260261
})
261262
})
262263
}

src/menu/List.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ class List extends BaseList {
106106

107107
/**
108108
* If the menu is floating, it will anchor itself to the parentRect
109-
* @member {Object|null} parentComponent=null
109+
* @member {Neo.component.Base|null} parentComponent=null
110+
*/
111+
parentComponent = null
112+
/**
113+
* If the menu is floating, it will anchor itself to the parentRect
114+
* @member {Object|null} parentRect=null
110115
*/
111116
parentRect = null
112117

@@ -176,6 +181,11 @@ class List extends BaseList {
176181
parentRect = me.parentRect;
177182

178183
if (value && parentRect) {
184+
Neo.main.addon.ScrollSync.register({
185+
sourceId: me.id,
186+
targetId: me.parentComponent.id
187+
})
188+
179189
me.getDomRect().then(rect => {
180190
let style = me.style || {};
181191

0 commit comments

Comments
 (0)