The document discusses changes to rendering and configuration in Touch 2. It explains that Touch 2 splits element creation and DOM placement during rendering. It also describes how layouts are now completely CSS-based. Configuration uses proper getters and setters to maintain the configuration lifecycle. Apply and update methods allow effective handling of configuration values.
4. Rendering in Touch 2
Touch 1 combinedthis process into two distinct pieces
Touch 2 splits Element creation and DOM placement
Creation
Placement
Wednesday, November 2, 2011
5. Rendering in Touch 2
Touch 1 combinedthis process into two distinct pieces
Touch 2 splits Element creation and DOM placement
Creation
Placement
Wednesday, November 2, 2011
6. Rendering in Touch 2
Touch 1 combinedthis process into two distinct pieces
Touch 2 splits Element creation and DOM placement
Creation
Placement
Wednesday, November 2, 2011
7. Rendering in Touch 2
The Element Creation process is now part of Component
instantiation
The Elements initially exist outside the DOM
You don’t want measure elements until they enter the DOM
Wednesday, November 2, 2011
8. Rendering in Touch 2
Touch 1 stored a DOM markup on the prototype
Touch 2 stores a DOM element on the prototype
element.cloneNode(true) for all instances
Wednesday, November 2, 2011
9. Rendering in Touch 2
Adding a Component to a Container will move its elements
inside the DOM - fires the ‘painted’ event
Removing a Component from a Container will move its elements
outside the DOM - fires the ‘erased’ event
Component.show() will place the Component in the ViewPort
Wednesday, November 2, 2011
10. Rendering in Touch 2
Being able to ‘erase’ components from the DOM and using
clean configurations allows the recycling of components
for (; i >= 0; i--) {
item = items[from + i];
if (cacheLn !== maxItemCache) {
me.remove(item, false);
item.removeCls([me.getPressedCls(), me.getSelectedCls()]);
itemCache.push(item);
cacheLn++;
}
else {
item.destroy();
}
}
Wednesday, November 2, 2011
11. Rendering in Touch 2
Being able to ‘erase’ components from the DOM and using
clean configurations allows the recycling of components
for (; i < ln; i++) {
record = records[i];
if (cacheLn) {
cacheLn--;
item = itemCache.pop();
item.setRecord(record);
items.push(item);
}
else {
items.push(me.getDataItemConfig(xtype, record, itemConfig));
}
}
Wednesday, November 2, 2011
12. Rendering in Touch 2
Unsupported Methods:
render
afterRender
The ‘render’ event is slated for deprecation
Wednesday, November 2, 2011
16. Layouts in Touch 2
Place elements in the appropriate DOM location
Apply CSS Layout classes
Apply layout configurations such as pack, flex, align, etc.
Wrap components for docking and centering
Wednesday, November 2, 2011
17. Layouts in Touch 2
Unsupported Methods:
doLayout
doComponentLayout
afterLayout
Wednesday, November 2, 2011
18. Layouts in Touch 2
Without afterLayout, how can you detect size changes?
Scroller
NavigationBar
Slider
DrawComponent
Wednesday, November 2, 2011
19. Layouts in Touch 2
Without afterLayout, how can you detect size changes?
Scroller
NavigationBar
Slider
DrawComponent
new Ext.util.SizeMonitor({
element: this.element,
callback: this.onSizeChange,
scope: this
});
Wednesday, November 2, 2011
20. Layouts in Touch 2
How does SizeMonitor work? Target Element
Add two absolutely
Detect Shrinking
positioned elements with
scroll listeners
If position and scroll don’t
match, we run our callback Detect Expanding
Wednesday, November 2, 2011
21. Layouts in Touch 2
Docking moved to Container
Wednesday, November 2, 2011
22. Layouts in Touch 2
Docking moved to Container
Remove Panel overnesting
Removed DataPanel
‘dockedItems’ deprecated
Dynamic Docking - dock configuration now accepts a boolean
Wednesday, November 2, 2011
23. Layouts in Touch 2
Setting top, left, bottom, or right will now float your component
‘floating’ configuration deprecated
percentage configuration for top, left, bottom, right, height,
and width are now supported
config: {
top: '20%',
left: '10%',
right: '10%',
bottom: '20%'
},
Wednesday, November 2, 2011
25. Configuration in Touch 2
Proper configurations are now used throughout Touch 2
Using proper getter and setters maintains the configuration
lifecycle
Wednesday, November 2, 2011
26. Configuration in Touch 2
Getters provide:
Lazy instantiation of the configuration on the first call
Ensures the initial configuration is passed through the setter
Configuration dependency handling
Wednesday, November 2, 2011
27. Configuration in Touch 2
Setters provide:
Execution of an optional apply method
A simple check for a change in value and a call to an optional
update method
Wednesday, November 2, 2011
28. Configuration in Touch 2
Using Apply effectively: Filtering
applyValue: function(value) {
var minValue = this.getMinValue(),
maxValue = this.getMaxValue();
value = parseFloat(Math.min(Math.max(value, minValue),
maxValue));
if (isNaN(value)) {
value = this.getDefaultValue();
}
return value;
},
Wednesday, November 2, 2011
29. Configuration in Touch 2
Using Apply effectively: Validation
applyActiveTab: function(activeTab) {
if (!activeTab && activeTab !== 0) {
return;
}
var activeTabInstance = this.parseActiveTab(activeTab);
if (!activeTabInstance) {
// <debug warn>
Ext.Logger.warn('Trying to set a non-existent activeTab');
// </debug>
return;
}
return activeTabInstance;
},
Wednesday, November 2, 2011
30. Configuration in Touch 2
Using Apply effectively: Transformation
applyLabel: function(config) {
if (typeof config == "string") {
config = {
text: config
};
}
return Ext.factory(config, 'Ext.form.Label', this.getLabel());
},
Wednesday, November 2, 2011
31. Configuration in Touch 2
Using Update effectively: Updating Dependencies
updateContentEl: function(newContentEl, oldContentEl) {
// Take care of the old contentEl
if (oldContentEl) {
oldContentEl.hide();
Ext.getBody().append(oldContentEl);
}
// Take care of the new contentEl
if (newContentEl) {
this.setHtml(newContentEl);
newContentEl.show();
}
},
Wednesday, November 2, 2011
32. Configuration in Touch 2
Wither initComponent
initComponent : function() {
...
if (!this.store) {
this.store = new Ext.data.Store({
model: 'IndexBarModel'
});
}
if (this.alphabet == true) {
this.ui = this.ui || 'alphabet';
}
Wednesday, November 2, 2011