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