SlideShare une entreprise Scribd logo
1  sur  20
Getting the Native Feel
 JavaScript for Mobile and Tablet HTML5 Apps



                      Bill Fisher
                   @fisherwebdev
               bill.hotstudiodev.com
overview
• HTML5 Apps vs. Native Apps
• Touchy: a jQuery plugin for touch events
• Get accelerated: js optimization + css
  animations
• Further considerations
iLose
• expensive to build for multiple platforms
• app store fees and rules
• loss of control over customer data
• no control over distribution channel and
  promotion/marketing issues
Financial Times
• Built by Assanka. Raises the bar.
• Use of HTML5 technologies and hacks to achieve
  an optimal user experience
• User promptedlocalsave to homescreen and to
  allow 50mb of
                 to
                     storage
• Last week: Financial Times kicked out of App Store
• Presentation on how they built it: http://
  vimeo.com/26604635
Hot Studio
• Recent work has been geared toward
  mobile or tablet
• Application frameworks like Sencha Touch
  or jQuery Mobile are too heavy-handed
• Need good control over the touch
  “environment”
touch event libraries

• touchscroll.js
• iscroll-4
• JSGestureRecognizer
• touchy - github.com/HotStudio/touchy
touchy: a jQuery plugin
• layered on top of ontouchstart, ontouchmove and
  ontouchend
• loosely based on native iOS gesture recognizers:
  drag, swipe, pinch, rotate, longpress
• architecture based on Ben Alman’s jQuery special
  events article
• event handlers receive the “phase” of the event in
  a parameter, in addition to other data
using touchy
Example #1
var handleTouchyPinch = function (e, $target, data) {
   $target.css('webkitTransform','scale(' + data.scale + ',' + data.scale + ')');
};
$('#my_div').bind('touchy-pinch', handleTouchyPinch);



Example #2
var degrees = 0,
   handleTouchyRotate = function (e, phase, $target, data) {

    if (phase === 'move') {

    
     degrees += data.degreeDelta;

    
     $target.css('webkitTransform','rotate3d(0,0,0,'+ degrees +'deg)');

    }
};
$('#my_div').bind('touchy-rotate', handleTouchyRotate);
event handlers: use css3

• Use 3D CSS for hardware acceleration
• *-transform: translateZ(0) or translate3d(0,0,0)

    hardware acceleration debugging:
    $ CA_COLOR_OPAQUE=1 /Developer/Platforms/iPhoneSimulator.platform/
    Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone
    Simulator
event handlers: javascript
• throttled frame rates
• name anonymous functions so they may be
  profiled
• separate reading and modifying of DOM values
  into two distinct phases of operation
things to avoid

• DOM manipulation: hit the DOM once
• accidental browser layout reflow
• animated css shadows and gradients
example uses of js + css3

 • HTML5 Rocks
 • http://desandro.com/
 • Touchy examples
further considerations
• base64 encoded images
• requestAnimationFrame
• offline use: save to homescreen + cache
  manifest + local storage
• W3C widgets
FTW
• build and advocate for optimized HTML5 apps
• create and contribute to open source projects
  that make development easier
• dream big and push the limits!
• open systems will win
Links: HTML5 Apps
HTML5 Apps vs. Native Apps
http://www.readwriteweb.com/mobile/2011/08/android-users-prefer-native-ov.php
http://www.mobiletech.mobi/blog/mobile-web-vs-native-apps-revisited/11672/
http://www.readwriteweb.com/archives/mobile_app_or_browser-based_site.php
http://www.readwriteweb.com/archives/web_vs_native_mobile_app_forrester_says_do_both.php


Financial Times HTML5 App
http://vimeo.com/26604635
http://www.ft.com/
Links: Touch
Touch Events and Touchy jQuery Plugin
https://github.com/HotStudio/touchy
https://github.com/davidaurelio/TouchScroll
https://github.com/mud/jsgesturerecognizer
https://github.com/cubiq/iscroll

developer.apple.com:
http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebcontent/HandlingEvents/HandlingEvents.html
http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/TouchEventClassReference/
http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/GestureEventClassReference/
Links: CSS3 and Perf
CSS3 Transforms and Animations
http://www.webkit.org/blog/386/3d-transforms/
http://desandro.github.com/3dtransforms/
http://www.html5rocks.com/en/tutorials/3d/css/
http://www.joelambert.co.uk/cssa/


Browser Optimization
http://paulirish.com/2011/dom-html5-css3-performance/
http://www.html5rocks.com/en/tutorials/speed/html5/
http://mir.aculo.us/2011/02/08/visualizing-webkits-hardware-acceleration/
http://calendar.perfplanet.com/2009/rendering-repaint-reflow-relayout-restyle/
http://www.slideshare.net/madrobby/extreme-javascript-performance
Thanks!
bill.hotstudiodev.com

Contenu connexe

Tendances

Marionette structure with modules
Marionette structure with modulesMarionette structure with modules
Marionette structure with modules
matt-briggs
 

Tendances (13)

Practical html5
Practical html5Practical html5
Practical html5
 
Native Device vs. Mobile Web Applications
Native Device vs. Mobile Web ApplicationsNative Device vs. Mobile Web Applications
Native Device vs. Mobile Web Applications
 
2014 Picking a Platform by Anand Kulkarni
2014 Picking a Platform by Anand Kulkarni2014 Picking a Platform by Anand Kulkarni
2014 Picking a Platform by Anand Kulkarni
 
Cinematic Interactives with Animate CC
Cinematic Interactives with Animate CCCinematic Interactives with Animate CC
Cinematic Interactives with Animate CC
 
Cross Platform Mobile Development
Cross Platform Mobile DevelopmentCross Platform Mobile Development
Cross Platform Mobile Development
 
Appurify - Runtime Debugging, Performance Optimization and Automated CI
Appurify - Runtime Debugging, Performance Optimization and Automated CIAppurify - Runtime Debugging, Performance Optimization and Automated CI
Appurify - Runtime Debugging, Performance Optimization and Automated CI
 
CC 2015 Single Page Applications for the ASPNET Developer
CC 2015   Single Page Applications for the ASPNET DeveloperCC 2015   Single Page Applications for the ASPNET Developer
CC 2015 Single Page Applications for the ASPNET Developer
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Marionette structure with modules
Marionette structure with modulesMarionette structure with modules
Marionette structure with modules
 
CA Plex on Apple Mac, iOS, Android
CA Plex on Apple Mac, iOS, AndroidCA Plex on Apple Mac, iOS, Android
CA Plex on Apple Mac, iOS, Android
 
Mobilizing Your Visualforce Application With JQuery and KnockoutJS
Mobilizing Your Visualforce Application With JQuery and KnockoutJSMobilizing Your Visualforce Application With JQuery and KnockoutJS
Mobilizing Your Visualforce Application With JQuery and KnockoutJS
 
Progressive Web Apps are here!
Progressive Web Apps are here!Progressive Web Apps are here!
Progressive Web Apps are here!
 
Jquery
JqueryJquery
Jquery
 

Similaire à Getting the-native-feel

Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
Chris Morrell
 
Mobile ECM with JavaScript - JSE 2011
Mobile ECM with JavaScript - JSE 2011Mobile ECM with JavaScript - JSE 2011
Mobile ECM with JavaScript - JSE 2011
Nuxeo
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
Mihail Mateev
 
Web app with j query & javascript (5:4)
Web app with j query & javascript (5:4)Web app with j query & javascript (5:4)
Web app with j query & javascript (5:4)
Thinkful
 
Html5 today
Html5 todayHtml5 today
Html5 today
Roy Yu
 
GeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPressGeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPress
GGDBologna
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)
Jia Mi
 

Similaire à Getting the-native-feel (20)

Mobile web or native app
Mobile web or native appMobile web or native app
Mobile web or native app
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
 
Mobile ECM with JavaScript - JSE 2011
Mobile ECM with JavaScript - JSE 2011Mobile ECM with JavaScript - JSE 2011
Mobile ECM with JavaScript - JSE 2011
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
Desarrollo de apps multiplataforma con tecnologías web
Desarrollo de apps multiplataforma con tecnologías webDesarrollo de apps multiplataforma con tecnologías web
Desarrollo de apps multiplataforma con tecnologías web
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanley
 
Web app with j query & javascript (5:4)
Web app with j query & javascript (5:4)Web app with j query & javascript (5:4)
Web app with j query & javascript (5:4)
 
AppNotch
AppNotchAppNotch
AppNotch
 
Html5 today
Html5 todayHtml5 today
Html5 today
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
 
The Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesThe Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devices
 
Things I've learnt from my Hacker News web app
Things I've learnt from my Hacker News web appThings I've learnt from my Hacker News web app
Things I've learnt from my Hacker News web app
 
Responsive Web Design - Tom Robertshaw
Responsive Web Design - Tom RobertshawResponsive Web Design - Tom Robertshaw
Responsive Web Design - Tom Robertshaw
 
The XPages Mobile Controls: What's New in Notes 9.0.1
The XPages Mobile Controls: What's New in Notes 9.0.1The XPages Mobile Controls: What's New in Notes 9.0.1
The XPages Mobile Controls: What's New in Notes 9.0.1
 
Mobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressMobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPress
 
GeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPressGeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPress
 
DjangoSki
DjangoSkiDjangoSki
DjangoSki
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)
 
Future of Mobile
Future of MobileFuture of Mobile
Future of Mobile
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Getting the-native-feel

  • 1. Getting the Native Feel JavaScript for Mobile and Tablet HTML5 Apps Bill Fisher @fisherwebdev bill.hotstudiodev.com
  • 2. overview • HTML5 Apps vs. Native Apps • Touchy: a jQuery plugin for touch events • Get accelerated: js optimization + css animations • Further considerations
  • 3. iLose • expensive to build for multiple platforms • app store fees and rules • loss of control over customer data • no control over distribution channel and promotion/marketing issues
  • 4.
  • 5.
  • 6. Financial Times • Built by Assanka. Raises the bar. • Use of HTML5 technologies and hacks to achieve an optimal user experience • User promptedlocalsave to homescreen and to allow 50mb of to storage • Last week: Financial Times kicked out of App Store • Presentation on how they built it: http:// vimeo.com/26604635
  • 7. Hot Studio • Recent work has been geared toward mobile or tablet • Application frameworks like Sencha Touch or jQuery Mobile are too heavy-handed • Need good control over the touch “environment”
  • 8. touch event libraries • touchscroll.js • iscroll-4 • JSGestureRecognizer • touchy - github.com/HotStudio/touchy
  • 9. touchy: a jQuery plugin • layered on top of ontouchstart, ontouchmove and ontouchend • loosely based on native iOS gesture recognizers: drag, swipe, pinch, rotate, longpress • architecture based on Ben Alman’s jQuery special events article • event handlers receive the “phase” of the event in a parameter, in addition to other data
  • 10. using touchy Example #1 var handleTouchyPinch = function (e, $target, data) { $target.css('webkitTransform','scale(' + data.scale + ',' + data.scale + ')'); }; $('#my_div').bind('touchy-pinch', handleTouchyPinch); Example #2 var degrees = 0, handleTouchyRotate = function (e, phase, $target, data) { if (phase === 'move') { degrees += data.degreeDelta; $target.css('webkitTransform','rotate3d(0,0,0,'+ degrees +'deg)'); } }; $('#my_div').bind('touchy-rotate', handleTouchyRotate);
  • 11. event handlers: use css3 • Use 3D CSS for hardware acceleration • *-transform: translateZ(0) or translate3d(0,0,0) hardware acceleration debugging: $ CA_COLOR_OPAQUE=1 /Developer/Platforms/iPhoneSimulator.platform/ Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator
  • 12. event handlers: javascript • throttled frame rates • name anonymous functions so they may be profiled • separate reading and modifying of DOM values into two distinct phases of operation
  • 13. things to avoid • DOM manipulation: hit the DOM once • accidental browser layout reflow • animated css shadows and gradients
  • 14. example uses of js + css3 • HTML5 Rocks • http://desandro.com/ • Touchy examples
  • 15. further considerations • base64 encoded images • requestAnimationFrame • offline use: save to homescreen + cache manifest + local storage • W3C widgets
  • 16. FTW • build and advocate for optimized HTML5 apps • create and contribute to open source projects that make development easier • dream big and push the limits! • open systems will win
  • 17. Links: HTML5 Apps HTML5 Apps vs. Native Apps http://www.readwriteweb.com/mobile/2011/08/android-users-prefer-native-ov.php http://www.mobiletech.mobi/blog/mobile-web-vs-native-apps-revisited/11672/ http://www.readwriteweb.com/archives/mobile_app_or_browser-based_site.php http://www.readwriteweb.com/archives/web_vs_native_mobile_app_forrester_says_do_both.php Financial Times HTML5 App http://vimeo.com/26604635 http://www.ft.com/
  • 18. Links: Touch Touch Events and Touchy jQuery Plugin https://github.com/HotStudio/touchy https://github.com/davidaurelio/TouchScroll https://github.com/mud/jsgesturerecognizer https://github.com/cubiq/iscroll developer.apple.com: http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebcontent/HandlingEvents/HandlingEvents.html http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/TouchEventClassReference/ http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/GestureEventClassReference/
  • 19. Links: CSS3 and Perf CSS3 Transforms and Animations http://www.webkit.org/blog/386/3d-transforms/ http://desandro.github.com/3dtransforms/ http://www.html5rocks.com/en/tutorials/3d/css/ http://www.joelambert.co.uk/cssa/ Browser Optimization http://paulirish.com/2011/dom-html5-css3-performance/ http://www.html5rocks.com/en/tutorials/speed/html5/ http://mir.aculo.us/2011/02/08/visualizing-webkits-hardware-acceleration/ http://calendar.perfplanet.com/2009/rendering-repaint-reflow-relayout-restyle/ http://www.slideshare.net/madrobby/extreme-javascript-performance

Notes de l'éditeur

  1. bill fisher, hot studio, slides in pdf at url, html5 app vs. web app \n
  2. peter-paul koch: html5 app\ntouch\ngetting the native feel in the event handlers\ni’ll briefly touch on other issues in developing html5 apps\n
  3. apple wants 30% from publishers...?\n
  4. \n
  5. \n
  6. Gives FT huge flexibility and leverage in negotiating with Apple. Do they even need Apple?\n\n
  7. Can’t talk directly about recent work, but it was an HTML5 app.\nLots of interest in mobile / tablet\nBecause touch is inherently more limited than a mouse and keyboard, the relationship between different actions can result in conflict...\n
  8. \n
  9. webkit cross browser -- mobile safari and android browser\nlink to ben alman at the end\ndata - pinch not only scale, but current center point. pinch only works in recent android.\n
  10. not necessary to maintain the lexical scope for “this” because you get $target\n\n3d transforms - next slide.\n\n
  11. more research here...\n\nold android and rotate + 3d ?\n
  12. Frame rates don’t need to be faster than 30fps, typically. definitely not more than 60fps, the refresh rate of the screen. Events fire more rapidly, so the response needs to be throttled.\nHTML5 Rocks, link at end.\n\n
  13. Manipulate DOM fragments, then plug them in.\nLots of things can trigger reflow. Any display:none, any check of offsetWidth, etc.\nCheck out Paul’s 30min video on browser optimization.\n
  14. \n
  15. lots more research...\n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n