Mphasize
30 Jun 2010, 2:32 PM
Hello,
I just spent a lot of time trying to get this to work, so I thought I might share this. I expect that most of my problems are simply due to the library being a beta. Anyway.... a short summary of my findings is to be found a the bottom.
What I'm trying to do: I want to have a nice semi-transparent toolbar on the top, which is able to fade in and out, or slide in and out whenever you tap the screen (say parent panel).
As a side notice, the handler property does not seem to be supported in the config options of panels, so I set up a custom handler with panel.mon(ui.el, { tap: tapContent }) after creating the panel.
So here's my setup....
Ext.Panel({
id: 'toolbartxt',
scroll:'vertical',
html: 'Pick a button, any button.',
fullscreen: true,
dockedItems: {
xtype: 'toolbar',
id : 'topBar',
cls: 'visible',
ui: 'dark',
dock: 'top',
overlay: true,
items: buttonsGroup1.concat(buttonsGroup2).concat(buttonsGroup3)
}
});
Using overlay makes it possible for the content to slide under the docked toolbar.
Then I hacked the transparent toolbars in the css
.x-toolbar { -webkit-opacity: 0.8; }
And now the trouble began....
The event handler is supposed to toggle the toolbar based on it's visibility, but (probably) because of setting the toolbar to semi-transparent, the function Toolbar.isVisible() is broken.
I fixed this by setting and checking for a custom class.
Then I wanted to animate, but the .show() and .hide() functions don't support the Config-Objects for animations yet
(I tried .hide({type: 'slide', direction: 'up'}), resulting in an error), so I had to setup custom animations in order to use the string identifier like .hide('slideUp'); ....
When I tried the same thing with .show('slideDown'), I found that .show() is somehow ignoring the animation altogether. After venturing into ext-touch.js, the reason was apparently in the onShow, where there is a switch (this.isFloating) which determines if the animation should be run or not. I don't know if the switch is not working properly (maybe because of overlay:true?) or whatever the reason, but I could get the animation to work by changing to the following:
onShow : function(animation) {
animation = animation || this.showAnimation;
if (this.floating) {
[...]
}
else {
this.getVisibilityEl().show();
/* new */
if (animation) {
Ext.anims[animation].run(this.el, {
out: false
});
this.showAnimation = animation;
}
/* end of new */
}
}
I am still working in a very simply example so I cannot yet say if my *fix* is not blowing up other parts.
So, the summary:
1) handler-property in config-object for Ext.Panel would be nice
2) showAnimation-property, show(animation), hide(animation) with support for config-objects would be nice
3) isVisible() should work, even if elements are semi-transparent
4) show(animation) should work on docked toolbars with overlay-property enabled.
Well, if I have missed something important to avoid all these issues, please enlighten me. Otherwise thanks for reading.
Best!
M
I just spent a lot of time trying to get this to work, so I thought I might share this. I expect that most of my problems are simply due to the library being a beta. Anyway.... a short summary of my findings is to be found a the bottom.
What I'm trying to do: I want to have a nice semi-transparent toolbar on the top, which is able to fade in and out, or slide in and out whenever you tap the screen (say parent panel).
As a side notice, the handler property does not seem to be supported in the config options of panels, so I set up a custom handler with panel.mon(ui.el, { tap: tapContent }) after creating the panel.
So here's my setup....
Ext.Panel({
id: 'toolbartxt',
scroll:'vertical',
html: 'Pick a button, any button.',
fullscreen: true,
dockedItems: {
xtype: 'toolbar',
id : 'topBar',
cls: 'visible',
ui: 'dark',
dock: 'top',
overlay: true,
items: buttonsGroup1.concat(buttonsGroup2).concat(buttonsGroup3)
}
});
Using overlay makes it possible for the content to slide under the docked toolbar.
Then I hacked the transparent toolbars in the css
.x-toolbar { -webkit-opacity: 0.8; }
And now the trouble began....
The event handler is supposed to toggle the toolbar based on it's visibility, but (probably) because of setting the toolbar to semi-transparent, the function Toolbar.isVisible() is broken.
I fixed this by setting and checking for a custom class.
Then I wanted to animate, but the .show() and .hide() functions don't support the Config-Objects for animations yet
(I tried .hide({type: 'slide', direction: 'up'}), resulting in an error), so I had to setup custom animations in order to use the string identifier like .hide('slideUp'); ....
When I tried the same thing with .show('slideDown'), I found that .show() is somehow ignoring the animation altogether. After venturing into ext-touch.js, the reason was apparently in the onShow, where there is a switch (this.isFloating) which determines if the animation should be run or not. I don't know if the switch is not working properly (maybe because of overlay:true?) or whatever the reason, but I could get the animation to work by changing to the following:
onShow : function(animation) {
animation = animation || this.showAnimation;
if (this.floating) {
[...]
}
else {
this.getVisibilityEl().show();
/* new */
if (animation) {
Ext.anims[animation].run(this.el, {
out: false
});
this.showAnimation = animation;
}
/* end of new */
}
}
I am still working in a very simply example so I cannot yet say if my *fix* is not blowing up other parts.
So, the summary:
1) handler-property in config-object for Ext.Panel would be nice
2) showAnimation-property, show(animation), hide(animation) with support for config-objects would be nice
3) isVisible() should work, even if elements are semi-transparent
4) show(animation) should work on docked toolbars with overlay-property enabled.
Well, if I have missed something important to avoid all these issues, please enlighten me. Otherwise thanks for reading.
Best!
M