]> git.proxmox.com Git - extjs.git/blame - extjs/packages/core/src/util/sizemonitor/OverflowChange.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / src / util / sizemonitor / OverflowChange.js
CommitLineData
6527f429
DM
1/**\r
2 * @private\r
3 */\r
4Ext.define('Ext.util.sizemonitor.OverflowChange', {\r
5\r
6 extend: 'Ext.util.sizemonitor.Abstract',\r
7\r
8 constructor: function(config) {\r
9 this.onExpand = Ext.Function.bind(this.onExpand, this);\r
10 this.onShrink = Ext.Function.bind(this.onShrink, this);\r
11\r
12 this.callParent(arguments);\r
13 },\r
14\r
15 getElementConfig: function() {\r
16 return {\r
17 reference: 'detectorsContainer',\r
18 classList: [Ext.baseCSSPrefix + 'size-monitors', 'overflowchanged'],\r
19 children: [\r
20 {\r
21 reference: 'expandMonitor',\r
22 className: 'expand',\r
23 children: [{\r
24 reference: 'expandHelper'\r
25 }]\r
26 },\r
27 {\r
28 reference: 'shrinkMonitor',\r
29 className: 'shrink',\r
30 children: [{\r
31 reference: 'shrinkHelper'\r
32 }]\r
33 }\r
34 ]\r
35 };\r
36 },\r
37\r
38 bindListeners: function(bind) {\r
39 var method = bind ? 'addEventListener' : 'removeEventListener';\r
40\r
41 this.expandMonitor[method](Ext.browser.is.Firefox ? 'underflow' : 'overflowchanged', this.onExpand, true);\r
42 this.shrinkMonitor[method](Ext.browser.is.Firefox ? 'overflow' : 'overflowchanged', this.onShrink, true);\r
43 },\r
44\r
45 onExpand: function(e) {\r
46 if (Ext.browser.is.Webkit && e.horizontalOverflow && e.verticalOverflow) {\r
47 return;\r
48 }\r
49\r
50 Ext.TaskQueue.requestRead('refresh', this);\r
51 },\r
52\r
53 onShrink: function(e) {\r
54 if (Ext.browser.is.Webkit && !e.horizontalOverflow && !e.verticalOverflow) {\r
55 return;\r
56 }\r
57\r
58 Ext.TaskQueue.requestRead('refresh', this);\r
59 },\r
60\r
61 refreshMonitors: function() {\r
62 if (this.destroyed) {\r
63 return;\r
64 }\r
65\r
66 var expandHelper = this.expandHelper,\r
67 shrinkHelper = this.shrinkHelper,\r
68 contentBounds = this.getContentBounds(),\r
69 width = contentBounds.width,\r
70 height = contentBounds.height,\r
71 style;\r
72\r
73 if (expandHelper && !expandHelper.destroyed) {\r
74 style = expandHelper.style;\r
75 style.width = (width + 1) + 'px';\r
76 style.height = (height + 1) + 'px';\r
77 }\r
78\r
79 if (shrinkHelper && !shrinkHelper.destroyed) {\r
80 style = shrinkHelper.style;\r
81 style.width = width + 'px';\r
82 style.height = height + 'px';\r
83 }\r
84\r
85 Ext.TaskQueue.requestRead('refresh', this);\r
86 }\r
87});\r