How to add custom css animation to an element in Sencha Touch? - sencha-touch-2.1

I have a panel in Sencha Touch. Inside of the panel I have a button. Now when I click on the button, I want to increase the width of the panel with custom css animations. This is my what I have tried so far.
Sencha Touch Code:
xtype:'panel'
id:'mypanel',
style:'width:300px;-webkit-transition:width 2s;transition:width 2s;'
items:
[
{
xtype:'button',
text:'Expand',
id:'expand'
}
]
Controller.js //on button click
Ext.getCmp('mypanel').addCls("expand");
Custom.css
.expand
{
width:600px;
}
Inside style of the panel, I have given some animation. But it doesnot work. Any help is appreciated.

You need to remove the inline style. And use 2 css classes.
Mypanel.js
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
config: {
centered: true,
cls: 'colapse', // Initialy added cls class
id: 'mypanel',
items: [
{
xtype: 'button',
itemId: 'mybutton',
text: 'MyButton'
}
],
listeners: [
{
fn: 'onMybuttonTap',
event: 'tap',
delegate: '#mybutton'
}
]
},
onMybuttonTap: function(button, e, eOpts) {
Ext.getCmp('mypanel').setCls('expand'); // resetting style on button tap
}
});
custom.js
.expand
{
width:600px;-webkit-transition:width 2s;transition:width 2s;
}
.colapse
{
width:300px;-webkit-transition:width 2s;transition:width 2s;
}
In the above code initially i added the cls "colapse" to the panel and on the button tap event i set the cls to "expand" to the panel using the following code "Ext.getCmp('mypanel').setCls('expand')".

Related

Extjs 6 uxiframe under items of panel is not scrollable in IOS10 IPad

I am working in Sencha Extjs 6.1 where i need to load document (pdf) in uxiframe, its working fine (scrolling) with IOS version below 10, but not in IOS 10 Ipad. it stuck it after small scroll of pdf page, but in IOS below 10 it scroll to complete page.
Following is my code :
Ext.define('MapViewer.view.main.HTMLPanel.HTMLPanel', {
extend: 'Ext.panel.Panel',
xtype: 'htmlpanel',
height:300,
header: false,
style: '-webkit-overflow-scrolling: touch !important;',
requires: ['MapViewer.view.main.HTMLPanel.HTMLPanelController'],
controller: 'htmlpanelcontroller',
tbar: {
items: [
{
cls: 'selectedButtonCls',
reference: 'iframePlanTekst',
itemId: 'iframePlanTekst',
header: false,
//glyph: 'xe902#icomoon', // plantekst
iconCls: 'icon-viewer_plantekst',
listeners: {
click: 'onButtonClick'
}
},
{
reference: 'iframeDiagram',
itemId: 'iframeDiagram',
header: false,
hidden: true,
//glyph: 'xe901#icomoon', // diagram
iconCls: 'icon-viewer_diagram',
listeners: {
click: 'onButtonClick'
}
}
]
},
items: [
{
xtype: 'uxiframe',
height: '99%',
cls:'textTouchCss',
itemId: 'htmluxpanel',
style: 'padding:10px 10px 5px 10px',
reference: 'htmluxpanel',
header: false
}
]
});
Where cls : textTouchCss is like:
.textTouchCss{
-webkit-overflow-scrolling: touch !important; overflow: scroll !important;
}
putting scrollable: true or scrollable :'y' will freezes the panel.
I am loading the path in uxiframe like
Ext.ComponentQuery.query("htmlpanel")[0].down('#htmluxpanel').load(path);
Can any one has idea, what should be done to make this scroll better in IOS 10 ? Please help.
thanks

Firefox extension Load page in popap

I want a firefox extension, so when you click on icon it opens popup and loads my page inside of the popup.
I have next issue. I need when I click on extension icon to pick up URL of the current tab and load my page in popup with sending that URL as query string.
So when you click on icon it opens popup and loads page like "http://example.com?url={current-URL}"
The issue is that it loads my page in popup once, and next time I click on extension it opens already rendered popup. Here is the code I am using:
var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");
var self = require("sdk/self");
var tabs = require('sdk/tabs');
var button = ToggleButton({
id: "my-button",
label: "My button",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onChange: handleChange
});
var panel = panels.Panel({
width: 700,
height: 543,
contentURL: 'http://example.com?url='+ tabs.activeTab.url,
contextMenu : true,
onHide: handleHide
});
function handleChange(state) {
if (state.checked) {
panel.show({
position: button
});
}
}
function handleHide() {
button.state('window', {checked: false});
}
So what I want is each time I click on extension icon it loads my page in panel AGAIN, not just show already rendered page. Is this possible and how I can do this, any help?
Panel's contentURL property has a setter defined, so changing the url is as simple as:
function handleChange(state) {
if (state.checked) {
panel.contentURL = 'http://example.com?url='+ tabs.activeTab.url,
panel.show({
position: button
});
}
}

Auto expand accordion on mouseover but prevent collapsing on mouseover

I am able to make my accordion automatically open a section on hover, but I don't know how to prevent it from collapsing a section when moving the mouse cursor over an active header of the accordion.
The following is my code:
$("#accordion").accordion({
event: 'mousedelay'
}).delegate('.ui-accordion-header', 'mouseover', function() {
clearTimeout($(this).closest('.ui-accordion').data('timeout'));
$(this).closest('.ui-accordion').data('timeout', setTimeout($.proxy(function() {
$(this).trigger('mousedelay');
}, this), 500));
});
How do I change the code so an active section would only collapse on click (not mouseover)?
After some fiddling (this is first time I tried jquery-ui), I solved my own problem:
$(document).ready(function() {
$( "#accordion" ).accordion( {
collapsible: true,
active: false,
icons: null,
animate: 500
});
$('#accordion').accordion({
event: 'mousedelay'
});
$('.ui-accordion-header')
.on('mouseover', function() {
clearTimeout($(this).closest('.ui-accordion').data('timeout'));
if (!$(this).hasClass('ui-state-active')) {
$(this).closest('.ui-accordion').data('timeout', setTimeout($.proxy(function() {
$(this).trigger('mousedelay');
}, this), 500));
};
})
.on('mouseleave', function() {
clearTimeout($(this).closest('.ui-accordion').data('timeout'));
})
.on('click', function() {
clearTimeout($(this).closest('.ui-accordion').data('timeout'));
if (!$(this).next('div').is(':animated')) { $(this).trigger('mousedelay'); }
});
});
The code works like this:
If the cursor is over an inactive header, the section expands after a delay
If the cursor is over an active header, do nothing
A mouse click toggles state of a section
Mute mouse click if the accordion is being animated

Prevent movement of user interface when keyboard appears

I'm working on a little app which uses Sencha Touch 2 for the user interface. Right now I'm running it in Safari on my iPad and iPhone.
My problem is that whenever I tap a text field, Safari brings up the virtual keyboard and pushes the whole web view upwards, off the screen.
This doesn't look very natural, since the top-toolbar is not visible anymore.
Here are two screenshots which demonstrate the problem.
In the second screenshot you can see the effect when the keyboard is visible.
Is there a way to prevent this behavior, and have Safari resize the user interface instead?
Unfortunately, Apple wants this behavior, but someone suggested a little hack using window.scrollTo():
listeners: {
focus: function() {
window.scrollTo(0,0);
}
}
Putting this code in launch function in app.js worked for me:
if (Ext.os.is.Android) {
Ext.Viewport.on('painted', function () {
Ext.Viewport.setHeight(window.innerHeight);
});
}
if (Ext.os.is.iOS) {
Ext.Viewport.on('painted', function () {
Ext.Viewport.setHeight(window.innerHeight);
});
}
I have found a solution that works for me.
You move the topbar into the container.
xtype: 'container',
docked: 'top',
height: '100%',
html: '',
itemId: 'MyContainer',
width: '100%',
items: [
{
xtype: 'titlebar',
docked: 'top',
itemId: 'topBar',
title: 'Obec Webchat',
layout: {
type: 'hbox',
align: 'start'
},
items: [
{
xtype: 'button',
action: 'back',
id: 'BackButton',
itemId: 'BackButton',
margin: '5 70% 5 15',
ui: 'back',
text: 'Home'
}
]
},
{
xtype: 'container',
docked: 'bottom',
height: '95%',
html: '<iframe src="http://webim.obec.local/" width="100%" height="100%" scrolling="yes"></iframe>',
itemId: 'MyContainer1',
width: '100%'
}
]
}
Hope this helps.
You will need to call the blur() method on textfield
// Assuming the id of textfield - "textFieldId"
Ext.getCmp('textFieldId').blur();
Attempts to forcefully blur input focus for the field.
If you this using html into Sencha elements must remove something tag html. Or can you put tag in the source html code. I hope help you. :)

Is There a Sencha Equivalent to jQuery's Radioset?

jQueryUI has a pretty nice display for radio buttons:
Does Sencha have anything similar?
Follow up question, if not:
what do you find to be nice UX for a three-item (or even four-item) component which requires only one touch? (e.g., a select box is two touches, one to open the select list and one to choose your option)
You are looking for Ext.SegmentedButton in Sencha Touch.
Sample code snippet:-
var segmentedButton = new Ext.SegmentedButton({
allowMultiple: false, // ensures only 1 button gets pressed at a time.
items: [
{
text: 'Choice 1'
},
{
text : 'Choice 2',
pressed: true
},
{
text: 'Choice 3'
}
],
listeners: {
toggle: function(container, button, pressed){
console.log("User toggled the '" + button.text + "' button: " + (pressed ? 'on' : 'off'));
}
}
});
Ext.Viewport.add({ xtype: 'container', padding: 10, items: [segmentedButton] });
Output :-

Resources