SlideShare a Scribd company logo
10 dicas de desempenho para 
apps mobile híbridas 
Loiane Groner 
http://loiane.com
Me, Myself && I 
! 
•Gerente de Desenv Projetos 
•8+ XP TI 
•Java, Sencha, Phonegap 
•http://loiane.com 
•@loiane
packpub.com 
amazon.com.br 
livrariacultura.com.br
Learning JavaScript 
Data Structures and 
Algorithms 
! 
Out/Nov 2014 
Ext JS 5 Avançado 
! 
Fev 2015
Nov 2013 
http://upgrade.ins-us.com/
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
I
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
#1
<div data-role="page" id="tracks">! 
! <div data-role="header"><h1>Tracks</h1></div>! 
! <ul data-role="listview">! 
! <li><a href="getTrackInfo.php?id=1">Desempenho e Escalabilidade na Prática</a></li>! 
! <li><a href="getTrackInfo.php?id=2">Java na Crista da Onda</a></li>! 
! <li><a href="getTrackInfo.php?id=3">Arquiteturas que Você Sempre Quis Conhecer</a></li>! 
! <li><a href="getTrackInfo.php?id=4">Mobile: Portáteis e Furiosos</a></li>! 
! </ul>! 
</div>!
NÃO gere páginas 
no servidor
Web Browser 
Dispositivo 
Web Server 
Java/PHP/ 
Ruby/C# 
Arquivos 
Imagens/ 
Documentos 
Banco de 
Dados 
Backend 
http:// 
Lógica de negócio 
JavaScript 
Arquivos 
Imagens/ 
Documentos 
Banco de 
Dados 
caching
JSON
#2
// Obtém dados! 
$.ajax({url: "getTrackInfo.php?id=1"}).done(function(track) {! 
// Mostra os detalhes - view! 
$.mobile.changePage($('#track-info'));! 
});!
//mostra View! 
$.mobile.changePage($('#track-info'));! 
! 
//------------------------------------------------------------------------! 
! 
$(document).bind("pagechange", onPageChange);! 
! 
function onPageChange(event, data) {! 
! var toPageId = data.toPage.attr("id");! 
! 
! switch (toPageId) {! 
case 'track-info':! 
! 
! clearValues();! 
! 
! // Obtém dados! 
! ! ! $.ajax({url: "getTrackInfo.php?id=1"}).done(function(track) {! 
! ! ! // Atualiza os detalhes - view! 
! ! ! $('#trackNome h1').html(track.name);! 
! ! ! ! $('#trackDesc').val(track.desc);! 
! ! ! ! $('#trackDia').val(track.dia);! 
! ! ! ! $('#trackLocal').val(track.local);! 
! ! ! ! $('#trackHost').val(track.host);! 
! ! ! });! 
! ! 
! break;! 
}! 
} !
Ext.define('MyContacts.store.Contacts', {! 
extend: 'Ext.data.Store',! 
! 
requires: [! 
'MyContacts.model.Contact',! 
'MyContacts.proxy.ContactsProxy'! 
],! 
! 
config: {! 
autoLoad: true,! 
model: 'MyContacts.model.Contact',! 
storeId: 'Contacts',! 
proxy: {! 
type: 'contactstorage'! 
}! 
}! 
});!
control: {! 
"contactslist": {! 
show: 'onListItemPainted'! 
}! 
}! 
! 
//-------------------------------------! 
! 
onListItemPainted: function(view, options) { ! 
view.getStore().load();! 
}!
Show 
me the 
VIEW!
Mostre a view e 
depois carregue os 
dados
#3
Ext.define('MyContacts.view.ContactsPanel', {! 
extend: 'Ext.Container',! 
alias: 'widget.contactspanel',! 
! 
requires: [! 
'MyContacts.view.ContactsList',! 
'MyContacts.view.ContactInfo',! 
'MyContacts.view.ContactEdit'! 
],! 
! 
config: {! 
layout: {! 
type: 'card'! 
},! 
items: [! 
{! 
xtype: 'contactslist'! 
},! 
{! 
xtype: 'contactinfo'! 
},! 
{! 
xtype: 'contactedit'! 
}! 
]! 
}! 
! 
});!
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
#4
App com lista dos participantes do FrontInBahia 
select count(*) from Participantes 
== 1000 
É muito dado?
Paging / Paginação 
https://github.com/stakbit/jQuery-Mobile-Listview-Pagination-Plugin 
http://dcarrith.github.io/jquery.mobile.lazyloader/
$.ajax({url: "listaEstadosBr.php"}).done(function(data) {! 
estadosBr = data;! 
});!
Dados Estáticos 
LocalStorage 
SQLite - database 
Arquivo - JSON
// do a SERVER load, passing a callback function! 
offlineSyncStore.loadServer(function(){! 
! 
// create a new Person record! 
var person = Ext.create('Person', {! 
FirstName: 'Joe',! 
LastName: 'Bloggs',! 
Email: 'joe@swarmonline.com'! 
});! 
! 
// add it to the store! 
offlineSyncStore.add(person);! 
! 
// sync the store LOCALLY. If autoServerSync is set to true then this will also sync using SERVER 
proxy! 
offlineSyncStore.sync();! 
! 
// if autoServerSync is false then call SERVER sync manually! 
offlineSyncStore.syncServer();! 
! 
});! 
https://market.sencha.com/extensions/ext-ux-offlinesyncstore
Faça cache dos 
dados
#5
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
var timeTouch;! 
! 
$("body").on("touchend", ".needsclick", function() {! 
timeTouch = new Date().getTime();! 
});! 
! 
$("body").on("click", ".needsclick", function() {! 
if (timeTouch) {! 
$("#log-slow").html("click: " + (new Date().getTime() - timeTouch) + "ms");! 
}! 
return false;! 
});!
Evite CLICK 
use TOUCHEND
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
Fastclick 
https://github.com/ftlabs/fastclick
$("body").on("touchend", ".fastclick", function() {! 
timeTouch = new Date().getTime();! 
});! 
! 
$("body").on("click", ".fastclick", function() {! 
if (timeTouch) {! 
$("#log-fast").html("touchend: " + (new Date().getTime() - timeTouch) + "ms");! 
} else {! 
alert("Execute esse exemplo em um device touch");! 
}! 
return false;! 
});!
#6
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
$("#page").animate();!
.page {! 
position: absolute;! 
width: 200px;! 
height:200px;! 
top:20px;! 
left:50;! 
}! 
! 
.page-left {! 
left: 50px;! 
}! 
.page-center {! 
left: 275px;! 
}! 
.page-right {! 
left: 500px;! 
}! 
! 
.transition {! 
transition-duration: .25s;! 
}!
Use CSS 3 
Transitions + 
Hardware 
Acceleration
.page {! 
position: absolute;! 
width: 200px;! 
height:200px;! 
top:20px;! 
left:50;! 
transform: translate3d(0,0,0);! 
}! 
! 
.page-left {! 
-webkit-transform: translate3d(30px, 0, 0);! 
transform: translate3d(31px, 0, 0);! 
}! 
.page-center {! 
-webkit-transform: translate3d(250px, 0, 0);! 
transform: translate3d(251px, 0, 0);! 
}! 
.page-right {! 
-webkit-transform: translate3d(470px, 0, 0);! 
transform: translate3d(471px, 0, 0);! 
}! 
! 
.transition {! 
-webkit-transition-duration: .25s;! 
transition-duration: .25s;! 
}!
Page Slider 
https://github.com/ccoenraets/PageSlider
#7
• box-shadow 
• border-radius 
• gradients 
• text-align
Evite sombras e 
gradientes
#8
$("#contato-info a.back").on("touchend", clickHandler);! 
$("#contato-info a.back").attr("href", "#contato-info");! 
$("#contato-info a.back").css("color", "green");! 
$("#contato-info a.back").css("text-decoration", "none");!
Ext.ComponentQuery.query('contactinfo button#back')[0].on('tap', clickHandler);! 
Ext.ComponentQuery.query('contactinfo button#back')[0].setCls('backBtn');! 
Ext.ComponentQuery.query('contactinfo button#back')[0].setLabelCls('labelCls');!
var $backBtn = $('#contato-info a.back');! 
$backBtn.on("touchend", clickHandler);! 
$backBtn.attr("href", "#contato-info");! 
$backBtn.css("color", "green");! 
$backBtn.css("text-decoration", "none");!
var backBtn = Ext.ComponentQuery.query('contactinfo button#back')[0];! 
backBtn.on('tap', clickHandler);! 
backBtn.setCls('backBtn');! 
backBtn.setLabelCls('labelCls');!
Minimize Browser 
Reflows
#9
XUI
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
x$(document).on("deviceready", function () {! 
! 
headingDiv = x$("#heading");! 
navigator.compass.getCurrentHeading(onSuccess, onError);! 
navigator.compass.watchHeading(onSuccess, onError, {frequency: 100});! 
! 
function onSuccess(heading) {! 
headingDiv.html(! 
'Heading: ' + heading.magneticHeading + '&#xb0; ' +! 
convertToText(heading.magneticHeading) + '<br />' +! 
'True Heading: ' + heading.trueHeading + '<br />' +! 
'Accuracy: ' + heading.headingAccuracy! 
);! 
! 
// Alter the CSS properties to rotate the rose image! 
x$(".rose").css({! 
"-webkit-transform":! 
"rotate(-" + heading.magneticHeading + "deg)",! 
"transform":! 
"rotate(-" + heading.magneticHeading + "deg)"! 
});! 
}! 
! 
function onError() {! 
headingDiv.html(! 
'There was an error trying to ' +! 
'locate your current bearing.'! 
);! 
}! 
});!
Topcoat
Cuidado com 
framework / lib da 
moda
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
#10
.icon-user {! 
background-image: url(../images/user.png) !important;! 
}! 
! 
.icon-user-add {! 
background-image: url(../images/user_add.gif) !important;! 
}! 
! 
.icon-save {! 
background-image: url(../images/save.gif) !important;! 
}! 
! 
.icon-reset {! 
background-image: url(../images/stop.png) !important;! 
}! 
! 
.icon-grid {! 
background-image: url(../images/grid.png) !important;! 
}! 
! 
.icon-add {! 
background-image: url(../images/add.png) !important;! 
}! 
! 
.icon-delete {! 
background-image: url(../images/delete.png) !important;! 
}!
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
.icon {! 
! background-image:url(result.png);! 
}! 
! 
.icon-user {! 
background-position: 0px -156px;! 
}! 
! 
.icon-user-add {! 
background-position: 0px -130px;! 
}! 
! 
.icon-save {! 
background-position: 0px -78px;! 
}! 
! 
.icon-reset {! 
background-position: 0px -104px;! 
}! 
! 
.icon-grid {! 
background-position: 0px -52px;! 
}! 
! 
.icon-add {! 
background-position: 0px 0px;! 
}! 
! 
.icon-delete {! 
background-position: 0px -26px;! 
}!
Build 
Otimizado 
Agrega Valor!
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
http://jquerymobile.com/download-builder/
OTIMIZE 
JS, CSS, HTML
http://browserdiet.com/pt/
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
https://github.com/loiane/mobile-hibrido-performance
http://loiane.com 
facebook.com/loianegroner 
@loiane 
https://github.com/loiane 
youtube.com/user/Loianeg
Obrigada!

More Related Content

PDF
Discontinuing Reader Matches
PDF
Javascript MVC & Backbone Tips & Tricks
PDF
Yearning jQuery
PDF
Mad Max is back, plus the rest of our new reviews and notable screenings
PDF
Before there was Hoop Dreams, there was McDonald's: Strange and Beautiful
PDF
Is HTML5 Ready? (workshop)
PDF
Cheap frontend tricks
PDF
jQuery: Events, Animation, Ajax
Discontinuing Reader Matches
Javascript MVC & Backbone Tips & Tricks
Yearning jQuery
Mad Max is back, plus the rest of our new reviews and notable screenings
Before there was Hoop Dreams, there was McDonald's: Strange and Beautiful
Is HTML5 Ready? (workshop)
Cheap frontend tricks
jQuery: Events, Animation, Ajax

What's hot (20)

PDF
The rise and fall of a techno DJ, plus more new reviews and notable screenings
PDF
HTML5 & The Open Web - at Nackademin
PDF
The Spirit of Testing
PPTX
course js day 3
DOCX
Borrador del blog
PDF
HTML5: where flash isn't needed anymore
PDF
Rushed to Victory Gardens' stage, An Issue of Blood is more effusion than play
PDF
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
KEY
jQuery Anti-Patterns for Performance & Compression
PPTX
Site optimization
PDF
jQuery UI and Plugins
PDF
TestWorks conf Dry up your angularjs unit tests using mox - Mike Woudenberg
TXT
Private slideshow
KEY
Html5 intro
PDF
Coffeescript - what's good
PPTX
FuncUnit
PDF
6주 javaScript 시작하며
TXT
https://www.facebook.com/valdyna.monna?fref=ts
PPTX
What your testtool doesn't tell you
KEY
Jarv.us Showcase — SenchaCon 2011
The rise and fall of a techno DJ, plus more new reviews and notable screenings
HTML5 & The Open Web - at Nackademin
The Spirit of Testing
course js day 3
Borrador del blog
HTML5: where flash isn't needed anymore
Rushed to Victory Gardens' stage, An Issue of Blood is more effusion than play
H3 경쟁력있는 웹앱 개발을 위한 모바일 js 프레임웍
jQuery Anti-Patterns for Performance & Compression
Site optimization
jQuery UI and Plugins
TestWorks conf Dry up your angularjs unit tests using mox - Mike Woudenberg
Private slideshow
Html5 intro
Coffeescript - what's good
FuncUnit
6주 javaScript 시작하며
https://www.facebook.com/valdyna.monna?fref=ts
What your testtool doesn't tell you
Jarv.us Showcase — SenchaCon 2011
Ad

Viewers also liked (20)

PDF
WebBr 2013: Apps Mobile Multiplataforma e OpenSource com Sencha Touch e Phon...
PDF
TDC2013: ExtJS 4: Dicas e Melhores Practicas
PDF
JavaCE Conference 2012: ExtJS 4 + VRaptor
PDF
Devcast Brasil: ExtJS 4 e Sencha Touch 2
PDF
JavaOne Brazil 2015: Java e HTML5
PDF
BeagaJS 2013: Sencha Touch + PhoneGap
PDF
Javaone Brazil 2012: Integrando Ext JS 4 com Java EE
PDF
MobileConf 2015: Desmistificando o Phonegap (Cordova)
PDF
School of Net Webinar: ExtJS 4
PDF
Conexao Java 2012: Desenvolvendo RIA com Java e Ext GWT (GXT)
PDF
FrontInFloripa 2013: Sencha Touch 2 e Phonegap
PDF
JavaOne Brazil 2011: Jax-RS e Ext JS 4
PDF
MNT2014: Mobile Hibrido com Phonegap
PDF
DevInCachu 2012 LT: Ext Gwt 3: GXT 3
PDF
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
PPT
DevInCachu 2012: Desenvolvendo Aplicacoes RIA com ExtJS 4 e Sencha Touch 2
PDF
QConSP 2012: Sencha Touch 2: Mobile Multiplataforma
PDF
TDC 2011 - Ext JS 4
PDF
JustJava 2013: Aplicações Desktop HTML5, CSS3, Javascript com Servlets 3
PDF
Cafe com Tom - ExtJS 4
WebBr 2013: Apps Mobile Multiplataforma e OpenSource com Sencha Touch e Phon...
TDC2013: ExtJS 4: Dicas e Melhores Practicas
JavaCE Conference 2012: ExtJS 4 + VRaptor
Devcast Brasil: ExtJS 4 e Sencha Touch 2
JavaOne Brazil 2015: Java e HTML5
BeagaJS 2013: Sencha Touch + PhoneGap
Javaone Brazil 2012: Integrando Ext JS 4 com Java EE
MobileConf 2015: Desmistificando o Phonegap (Cordova)
School of Net Webinar: ExtJS 4
Conexao Java 2012: Desenvolvendo RIA com Java e Ext GWT (GXT)
FrontInFloripa 2013: Sencha Touch 2 e Phonegap
JavaOne Brazil 2011: Jax-RS e Ext JS 4
MNT2014: Mobile Hibrido com Phonegap
DevInCachu 2012 LT: Ext Gwt 3: GXT 3
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
DevInCachu 2012: Desenvolvendo Aplicacoes RIA com ExtJS 4 e Sencha Touch 2
QConSP 2012: Sencha Touch 2: Mobile Multiplataforma
TDC 2011 - Ext JS 4
JustJava 2013: Aplicações Desktop HTML5, CSS3, Javascript com Servlets 3
Cafe com Tom - ExtJS 4
Ad

Similar to FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas (20)

PDF
Turn your spaghetti code into ravioli with JavaScript modules
PDF
jQtouch, Building Awesome Webapps
PDF
Velocity EU 2014 — Offline-first web apps
KEY
Paris js extensions
KEY
Building a real life application in node js
ODP
Scti 2011 minicurso jquery
TXT
Java.script
TXT
Html
PDF
HTML5 and CSS3 Shizzle
PDF
Building iPhone Web Apps using "classic" Domino
KEY
Taking your Web App for a walk
KEY
[Coscup 2012] JavascriptMVC
PDF
Bonnes pratiques de développement avec Node js
KEY
Device deployment
PDF
jQuery - 10 Time-Savers You (Maybe) Don't Know
KEY
jQuery: Tips, tricks and hints for better development and Performance
KEY
The go-start webframework (GTUG Vienna 27.03.2012)
PDF
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
PDF
Backbone.js — Introduction to client-side JavaScript MVC
PDF
Future of Web Development
Turn your spaghetti code into ravioli with JavaScript modules
jQtouch, Building Awesome Webapps
Velocity EU 2014 — Offline-first web apps
Paris js extensions
Building a real life application in node js
Scti 2011 minicurso jquery
Java.script
Html
HTML5 and CSS3 Shizzle
Building iPhone Web Apps using "classic" Domino
Taking your Web App for a walk
[Coscup 2012] JavascriptMVC
Bonnes pratiques de développement avec Node js
Device deployment
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery: Tips, tricks and hints for better development and Performance
The go-start webframework (GTUG Vienna 27.03.2012)
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
Backbone.js — Introduction to client-side JavaScript MVC
Future of Web Development

Recently uploaded (20)

PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
A Presentation on Artificial Intelligence
PDF
project resource management chapter-09.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Getting Started with Data Integration: FME Form 101
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A comparative study of natural language inference in Swahili using monolingua...
Chapter 5: Probability Theory and Statistics
1 - Historical Antecedents, Social Consideration.pdf
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
Web App vs Mobile App What Should You Build First.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A comparative analysis of optical character recognition models for extracting...
A Presentation on Artificial Intelligence
project resource management chapter-09.pdf
Unlocking AI with Model Context Protocol (MCP)
Programs and apps: productivity, graphics, security and other tools
Getting Started with Data Integration: FME Form 101
OMC Textile Division Presentation 2021.pptx
NewMind AI Weekly Chronicles - August'25-Week II

FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas

  • 1. 10 dicas de desempenho para apps mobile híbridas Loiane Groner http://loiane.com
  • 2. Me, Myself && I ! •Gerente de Desenv Projetos •8+ XP TI •Java, Sencha, Phonegap •http://loiane.com •@loiane
  • 4. Learning JavaScript Data Structures and Algorithms ! Out/Nov 2014 Ext JS 5 Avançado ! Fev 2015
  • 10. I
  • 12. #1
  • 13. <div data-role="page" id="tracks">! ! <div data-role="header"><h1>Tracks</h1></div>! ! <ul data-role="listview">! ! <li><a href="getTrackInfo.php?id=1">Desempenho e Escalabilidade na Prática</a></li>! ! <li><a href="getTrackInfo.php?id=2">Java na Crista da Onda</a></li>! ! <li><a href="getTrackInfo.php?id=3">Arquiteturas que Você Sempre Quis Conhecer</a></li>! ! <li><a href="getTrackInfo.php?id=4">Mobile: Portáteis e Furiosos</a></li>! ! </ul>! </div>!
  • 14. NÃO gere páginas no servidor
  • 15. Web Browser Dispositivo Web Server Java/PHP/ Ruby/C# Arquivos Imagens/ Documentos Banco de Dados Backend http:// Lógica de negócio JavaScript Arquivos Imagens/ Documentos Banco de Dados caching
  • 16. JSON
  • 17. #2
  • 18. // Obtém dados! $.ajax({url: "getTrackInfo.php?id=1"}).done(function(track) {! // Mostra os detalhes - view! $.mobile.changePage($('#track-info'));! });!
  • 19. //mostra View! $.mobile.changePage($('#track-info'));! ! //------------------------------------------------------------------------! ! $(document).bind("pagechange", onPageChange);! ! function onPageChange(event, data) {! ! var toPageId = data.toPage.attr("id");! ! ! switch (toPageId) {! case 'track-info':! ! ! clearValues();! ! ! // Obtém dados! ! ! ! $.ajax({url: "getTrackInfo.php?id=1"}).done(function(track) {! ! ! ! // Atualiza os detalhes - view! ! ! ! $('#trackNome h1').html(track.name);! ! ! ! ! $('#trackDesc').val(track.desc);! ! ! ! ! $('#trackDia').val(track.dia);! ! ! ! ! $('#trackLocal').val(track.local);! ! ! ! ! $('#trackHost').val(track.host);! ! ! ! });! ! ! ! break;! }! } !
  • 20. Ext.define('MyContacts.store.Contacts', {! extend: 'Ext.data.Store',! ! requires: [! 'MyContacts.model.Contact',! 'MyContacts.proxy.ContactsProxy'! ],! ! config: {! autoLoad: true,! model: 'MyContacts.model.Contact',! storeId: 'Contacts',! proxy: {! type: 'contactstorage'! }! }! });!
  • 21. control: {! "contactslist": {! show: 'onListItemPainted'! }! }! ! //-------------------------------------! ! onListItemPainted: function(view, options) { ! view.getStore().load();! }!
  • 22. Show me the VIEW!
  • 23. Mostre a view e depois carregue os dados
  • 24. #3
  • 25. Ext.define('MyContacts.view.ContactsPanel', {! extend: 'Ext.Container',! alias: 'widget.contactspanel',! ! requires: [! 'MyContacts.view.ContactsList',! 'MyContacts.view.ContactInfo',! 'MyContacts.view.ContactEdit'! ],! ! config: {! layout: {! type: 'card'! },! items: [! {! xtype: 'contactslist'! },! {! xtype: 'contactinfo'! },! {! xtype: 'contactedit'! }! ]! }! ! });!
  • 27. #4
  • 28. App com lista dos participantes do FrontInBahia select count(*) from Participantes == 1000 É muito dado?
  • 29. Paging / Paginação https://github.com/stakbit/jQuery-Mobile-Listview-Pagination-Plugin http://dcarrith.github.io/jquery.mobile.lazyloader/
  • 31. Dados Estáticos LocalStorage SQLite - database Arquivo - JSON
  • 32. // do a SERVER load, passing a callback function! offlineSyncStore.loadServer(function(){! ! // create a new Person record! var person = Ext.create('Person', {! FirstName: 'Joe',! LastName: 'Bloggs',! Email: '[email protected]'! });! ! // add it to the store! offlineSyncStore.add(person);! ! // sync the store LOCALLY. If autoServerSync is set to true then this will also sync using SERVER proxy! offlineSyncStore.sync();! ! // if autoServerSync is false then call SERVER sync manually! offlineSyncStore.syncServer();! ! });! https://market.sencha.com/extensions/ext-ux-offlinesyncstore
  • 34. #5
  • 36. var timeTouch;! ! $("body").on("touchend", ".needsclick", function() {! timeTouch = new Date().getTime();! });! ! $("body").on("click", ".needsclick", function() {! if (timeTouch) {! $("#log-slow").html("click: " + (new Date().getTime() - timeTouch) + "ms");! }! return false;! });!
  • 37. Evite CLICK use TOUCHEND
  • 40. $("body").on("touchend", ".fastclick", function() {! timeTouch = new Date().getTime();! });! ! $("body").on("click", ".fastclick", function() {! if (timeTouch) {! $("#log-fast").html("touchend: " + (new Date().getTime() - timeTouch) + "ms");! } else {! alert("Execute esse exemplo em um device touch");! }! return false;! });!
  • 41. #6
  • 44. .page {! position: absolute;! width: 200px;! height:200px;! top:20px;! left:50;! }! ! .page-left {! left: 50px;! }! .page-center {! left: 275px;! }! .page-right {! left: 500px;! }! ! .transition {! transition-duration: .25s;! }!
  • 45. Use CSS 3 Transitions + Hardware Acceleration
  • 46. .page {! position: absolute;! width: 200px;! height:200px;! top:20px;! left:50;! transform: translate3d(0,0,0);! }! ! .page-left {! -webkit-transform: translate3d(30px, 0, 0);! transform: translate3d(31px, 0, 0);! }! .page-center {! -webkit-transform: translate3d(250px, 0, 0);! transform: translate3d(251px, 0, 0);! }! .page-right {! -webkit-transform: translate3d(470px, 0, 0);! transform: translate3d(471px, 0, 0);! }! ! .transition {! -webkit-transition-duration: .25s;! transition-duration: .25s;! }!
  • 48. #7
  • 49. • box-shadow • border-radius • gradients • text-align
  • 50. Evite sombras e gradientes
  • 51. #8
  • 52. $("#contato-info a.back").on("touchend", clickHandler);! $("#contato-info a.back").attr("href", "#contato-info");! $("#contato-info a.back").css("color", "green");! $("#contato-info a.back").css("text-decoration", "none");!
  • 53. Ext.ComponentQuery.query('contactinfo button#back')[0].on('tap', clickHandler);! Ext.ComponentQuery.query('contactinfo button#back')[0].setCls('backBtn');! Ext.ComponentQuery.query('contactinfo button#back')[0].setLabelCls('labelCls');!
  • 54. var $backBtn = $('#contato-info a.back');! $backBtn.on("touchend", clickHandler);! $backBtn.attr("href", "#contato-info");! $backBtn.css("color", "green");! $backBtn.css("text-decoration", "none");!
  • 55. var backBtn = Ext.ComponentQuery.query('contactinfo button#back')[0];! backBtn.on('tap', clickHandler);! backBtn.setCls('backBtn');! backBtn.setLabelCls('labelCls');!
  • 57. #9
  • 58. XUI
  • 60. x$(document).on("deviceready", function () {! ! headingDiv = x$("#heading");! navigator.compass.getCurrentHeading(onSuccess, onError);! navigator.compass.watchHeading(onSuccess, onError, {frequency: 100});! ! function onSuccess(heading) {! headingDiv.html(! 'Heading: ' + heading.magneticHeading + '&#xb0; ' +! convertToText(heading.magneticHeading) + '<br />' +! 'True Heading: ' + heading.trueHeading + '<br />' +! 'Accuracy: ' + heading.headingAccuracy! );! ! // Alter the CSS properties to rotate the rose image! x$(".rose").css({! "-webkit-transform":! "rotate(-" + heading.magneticHeading + "deg)",! "transform":! "rotate(-" + heading.magneticHeading + "deg)"! });! }! ! function onError() {! headingDiv.html(! 'There was an error trying to ' +! 'locate your current bearing.'! );! }! });!
  • 62. Cuidado com framework / lib da moda
  • 64. #10
  • 65. .icon-user {! background-image: url(../images/user.png) !important;! }! ! .icon-user-add {! background-image: url(../images/user_add.gif) !important;! }! ! .icon-save {! background-image: url(../images/save.gif) !important;! }! ! .icon-reset {! background-image: url(../images/stop.png) !important;! }! ! .icon-grid {! background-image: url(../images/grid.png) !important;! }! ! .icon-add {! background-image: url(../images/add.png) !important;! }! ! .icon-delete {! background-image: url(../images/delete.png) !important;! }!
  • 67. .icon {! ! background-image:url(result.png);! }! ! .icon-user {! background-position: 0px -156px;! }! ! .icon-user-add {! background-position: 0px -130px;! }! ! .icon-save {! background-position: 0px -78px;! }! ! .icon-reset {! background-position: 0px -104px;! }! ! .icon-grid {! background-position: 0px -52px;! }! ! .icon-add {! background-position: 0px 0px;! }! ! .icon-delete {! background-position: 0px -26px;! }!
  • 76. http://loiane.com facebook.com/loianegroner @loiane https://github.com/loiane youtube.com/user/Loianeg