This chapter discusses programming for touchscreens and mobile devices in JavaScript. It covers using touch, pointer, and geolocation events to integrate mouse and touch interactions. It also provides ways to optimize mobile web apps, such as minimizing file sizes and loading scripts responsively. The chapter aims to help developers make their apps accessible and functional across different mobile platforms and input types.
JQuery provides methods to manipulate DOM in efficient way. You do not need to write big code to modify the value of any element's attribute or to extract HTML code from a paragraph or division.
JQuery provides methods such as .attr(), .html(), and .val() which act as getters, retrieving information from DOM elements for later use.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
JQuery provides methods to manipulate DOM in efficient way. You do not need to write big code to modify the value of any element's attribute or to extract HTML code from a paragraph or division.
JQuery provides methods such as .attr(), .html(), and .val() which act as getters, retrieving information from DOM elements for later use.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
Palestra apresentada no 1º Femug Joinville.
Códigos de exemplo usados na talk:
https://github.com/fdaciuk/talks/tree/master/2016/01-femug-jlle
Versão com Gifs:
https://docs.google.com/presentation/d/10AZ_sJZZmw3BeaZ54lyzfYLp51YiCHA4_o7X8XSNDV4/present
Building React Applications with Redux
with Yuri Takhteyev
OVERVIEW
Since React is just a “view framework”, it leaves you with lots of options for how to architect the deeper parts of your stack. The best way to handle those deeper layers is by using Redux – a state container that allows you to write much of your application in the form of pure functions. Using Redux helps you write applications that are much easier to test and understand and to achieve more thorough separation between your views and your business logic. Redux also unlocks the possibility of using amazing tools.
OBJECTIVE
Introduce the audience to Redux, a state container that can be used together with React to achieve sanity deeper down in your stack.
TARGET AUDIENCE
Developers familiar with core React and looking for a better way to architect their applications.
ASSUMED AUDIENCE KNOWLEDGE
Core React knowledge is assumed. Familiarity with basic Flux concepts would help, but I’ll review those quickly.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
Why pure functions make your code easier to maintain.
How unidirectional data flows help you sleep better at night.
How Redux helps you manage state better via reducers.
How to use Redux together with React.
How to test Redux applications.
All Things Open 2014 - Day 2
Thursday, October 23rd, 2014
James Pearce
Head of Open Source with Facebook
Front Dev 1
An Introduction to ReactJS
Find more by James here: https://speakerdeck.com/jamesgpearce
This is the first half of a presentation I gave at Squares Conference 2015 where I provided a brief introduction to React JS, then did live coding for 20 minutes to show more of the specifics of usage. Your milage may vary as the live code part was where the bulk of the teaching happened!
Sharing code in between react components by using render props. HOC and react prop are some of the best ways to share code in react class components.
#hoc #react #renderprop
On May 14, 2015, Jeff Winkler gave a talk at Harvard University's Lamont Library titled "Intro to ReactJS."
Description
Created by Facebook and Instagram, React has recently been embraced by companies and organizations including Airbnb, Khan Academy, Reddit, the BBC, and Code Academy. This presentation will be especially interesting for those using or planning to use javascript libraries such as angularJS, backbone.js, ember.js, and others.
For this talk, Jeff Winkler will present:
- An introduction to React, mixed with demos.
- An examination of how React implements Computer Science principles from Functional and Object-Oriented. The discussion will consider the impact on maintainable large-scale systems.
Biography
Jeff Winkler, is a professional developer* in the Boston area and organizer of the Boston ReactJS Meetup. In addition to the ReactJS Boston Meetup, Jeff works with React professionally at TapJoy and runs http://react.rocks.
(* Full-stack guy. ReactJS, Rails, TDD. Best OODA loop wins)
React is a fantastic Javascript rendering framework with a steep learning curve. One of the reasons is understanding state. We explore unidirectional flow, props, state Immutability and Redux.
Palestra apresentada no 1º Femug Joinville.
Códigos de exemplo usados na talk:
https://github.com/fdaciuk/talks/tree/master/2016/01-femug-jlle
Versão com Gifs:
https://docs.google.com/presentation/d/10AZ_sJZZmw3BeaZ54lyzfYLp51YiCHA4_o7X8XSNDV4/present
Building React Applications with Redux
with Yuri Takhteyev
OVERVIEW
Since React is just a “view framework”, it leaves you with lots of options for how to architect the deeper parts of your stack. The best way to handle those deeper layers is by using Redux – a state container that allows you to write much of your application in the form of pure functions. Using Redux helps you write applications that are much easier to test and understand and to achieve more thorough separation between your views and your business logic. Redux also unlocks the possibility of using amazing tools.
OBJECTIVE
Introduce the audience to Redux, a state container that can be used together with React to achieve sanity deeper down in your stack.
TARGET AUDIENCE
Developers familiar with core React and looking for a better way to architect their applications.
ASSUMED AUDIENCE KNOWLEDGE
Core React knowledge is assumed. Familiarity with basic Flux concepts would help, but I’ll review those quickly.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
Why pure functions make your code easier to maintain.
How unidirectional data flows help you sleep better at night.
How Redux helps you manage state better via reducers.
How to use Redux together with React.
How to test Redux applications.
All Things Open 2014 - Day 2
Thursday, October 23rd, 2014
James Pearce
Head of Open Source with Facebook
Front Dev 1
An Introduction to ReactJS
Find more by James here: https://speakerdeck.com/jamesgpearce
This is the first half of a presentation I gave at Squares Conference 2015 where I provided a brief introduction to React JS, then did live coding for 20 minutes to show more of the specifics of usage. Your milage may vary as the live code part was where the bulk of the teaching happened!
Sharing code in between react components by using render props. HOC and react prop are some of the best ways to share code in react class components.
#hoc #react #renderprop
On May 14, 2015, Jeff Winkler gave a talk at Harvard University's Lamont Library titled "Intro to ReactJS."
Description
Created by Facebook and Instagram, React has recently been embraced by companies and organizations including Airbnb, Khan Academy, Reddit, the BBC, and Code Academy. This presentation will be especially interesting for those using or planning to use javascript libraries such as angularJS, backbone.js, ember.js, and others.
For this talk, Jeff Winkler will present:
- An introduction to React, mixed with demos.
- An examination of how React implements Computer Science principles from Functional and Object-Oriented. The discussion will consider the impact on maintainable large-scale systems.
Biography
Jeff Winkler, is a professional developer* in the Boston area and organizer of the Boston ReactJS Meetup. In addition to the ReactJS Boston Meetup, Jeff works with React professionally at TapJoy and runs http://react.rocks.
(* Full-stack guy. ReactJS, Rails, TDD. Best OODA loop wins)
React is a fantastic Javascript rendering framework with a steep learning curve. One of the reasons is understanding state. We explore unidirectional flow, props, state Immutability and Redux.
By Philip Tellis and Nic Jansma
Whenever we speak of measuring web performance, we always refer to measuring static events, whether the old page-load model, the controversial above-the-fold time, or the product-specific “time to first tweet.” Each of these have their pros and cons ranging from ease of implementation to relevance to the actual user’s experience.
But a performant user experience is much more than these static events, and no methods measure the experience the user has interacting with the page after that initial event. We seldom measure the experience of the user when they spend the most time on the site (i.e., between load and unload, when they’re reading and interacting with content on the page, etc.) or ask questions like: Was scrolling smooth or janky? What about animations? Did the user click expecting something to happen but nothing did? Are too many reflows happening?
Drawing on their work on boomerang, Philip Tellis and Nic Jansma explore new methods of measuring web performance as it relates to continuous interactions between the user and a page.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
2. JavaScript, Sixth Edition 2
Objectives
When you complete this chapter, you will be able to:
• Integrate mouse, touch, and pointer events into a
web app
• Obtain and work with a user's geolocation
information
• Optimize a mobile web app to accommodate the
common constraints experienced by mobile users
3. JavaScript, Sixth Edition 3
Using Touch Events and Pointer
Events
• On touchscreen device without a moust
– browsers fire click event when user touches screen
• Other events don't translate neatly for touchscreens
4. JavaScript, Sixth Edition 4
Creating a Drag-and Drop Application
with Mouse Events
• Mouse events
– events based on actions of mouse or touchpad
Table 10-1 Mouse events
5. JavaScript, Sixth Edition 5
Understanding Mouse Events on a
Touchscreen Device
• On a touchscreen device
– Some web page elements respond to mouse events
– div element not considered clickable
• doesn't fire mouse events on touchscreen
– links and form elements are clickable
• browsers respond to touch
• Touch cascade
– Browser checks a touched element for an event
handler for multiple events
• Including some mouse events
6. JavaScript, Sixth Edition 6
Understanding Mouse Events on a
Touchscreen Device (cont'd.)
Figure 10-5 Touch cascade order
7. JavaScript, Sixth Edition 7
Understanding Mouse Events on a
Touchscreen Device (cont'd.)
• Touchscreen devices fire touchscreen-specific
events for some elements
– Touch events created by Apple
• Used on Apple iOS and Google Android
– Pointer events created by Microsoft
• Used on Windows Phone and Windows 8 and higher
8. JavaScript, Sixth Edition 8
Implementing Touch Events
• Respond to user's finger touches on a touchscreen
Table 10-2 Touch events
9. JavaScript, Sixth Edition 9
Implementing Touch Events (cont'd.)
• touchstart event
– analogous to mousedown mouse event
• touchmove event
– corresponds to mousemove
• touchend event
– similar to mouseup
• touchcancel event
– unique to touchscreen
10. JavaScript, Sixth Edition 10
Implementing Touch Events (cont'd.)
• Working with Touch Coordinates
– Mouse events can work with event properties
• clientX property = x coordinate of event
• clientY property = y coordinate of event
– Touch events support multitouch devices
• Allow for multiple touches on screen at once
• Don't support clientX or clientY properties as
direct children
• Each touch event has array properties
12. JavaScript, Sixth Edition 12
Implementing Touch Events (cont'd.)
• Distinguishing Between App and Device Interaction
– Touchscreen devices use touch events for more than
one purpose
• Can interact via touch with an app
• Use touch to perform gestures
– Browser and device interactions like scrolling
– Use preventDefault() method
• Ensures that OS interface doesn't respond to events
when users interact with your app
13. JavaScript, Sixth Edition 13
Implementing Touch Events (cont'd.)
Figure 10-7 Multiple uses of a single touch event
14. JavaScript, Sixth Edition 14
Implementing Pointer Events
• Touchscreens on new types of devices
– Tablets
– Notebook computers
• Makes coding for touch and mouse events more
complicated
– Some devices support stylus input
– Some devices have trackpads
15. JavaScript, Sixth Edition 15
Implementing Pointer Events (cont'd.)
• Microsoft pointer events
– Aim to handle input from mouse, finger, or stylus with
each event
– Incorporate other event properties
• Pressure on screen
• Angle of stylus
• Only IE Mobile and IE 10 and later support pointer
events
• Some versions of IE do not recognize touch events
– Use mouse+touch+pointer for max. compatibility
17. JavaScript, Sixth Edition 17
Implementing Pointer Events (cont'd.)
• Identifying pointer screen coordinates
– clientX and clientY properties like mouse events
• Stopping OS gestures
– Requires setting msTouchAction CSS property
• Set value to none
18. JavaScript, Sixth Edition 18
Using Programming Interfaces for
Mobile Devices
• APIs available to access information provided by
mobile device hardware
Table 10-5 Selected hardware APIs for mobile devices
19. JavaScript, Sixth Edition 19
Using the Geolocation API
• Provides access to user's latitude & longitude
• Accessed using geolocation property of
Navigator object
Table 10-5 Selected hardware APIs for mobile devices
20. JavaScript, Sixth Edition 20
Using the Geolocation API (cont'd.)
• Callbacks
– Arguments that contain/reference executable code
• getCurrentPosition() method
– Request user's position a single time
21. JavaScript, Sixth Edition 21
Using the Geolocation API (cont'd.)
Table 10-7 Properties passed on a successful geolocation request
22. JavaScript, Sixth Edition 22
Using the Geolocation API (cont'd.)
• Basic example:
navigator.geolocation.getCurrentPosition(showLocation);
function showLocation(position) {
console.log("Longitude: " + position.coords.longitude);
console.log("Latitude: " + position.coords.latitude);
}
23. JavaScript, Sixth Edition 23
Using the Geolocation API (cont'd.)
• Enhanced example
– Handle failed request, set 10-second timeout:
navigator.geolocation.getCurrentPosition(showLocation, fail,↵
{timeout: 10000});
function showLocation(position) {
console.log("Longitude: " + position.coords.longitude);
console.log("Latitude: " + position.coords.latitude);
}
function fail() {
var content = document.getElementById("mainParagraph");
content.innerHTML = "<p>Geolocation information not↵
available or not authorized.</p>";
24. JavaScript, Sixth Edition 24
Using the Geolocation API (cont'd.)
• Need to fail gracefully in older browsers
if (navigator.geolocation {
navigator.geolocation.getCurrentPosition(createDirections,↵
fail, {timeout: 10000});
} else {
fail();
}
25. JavaScript, Sixth Edition 25
Using the Geolocation API (cont'd.)
• Need to clear geolocation history for testing
Table 10-9 Steps to clear saved geolocation history
26. JavaScript, Sixth Edition 26
Using the Geolocation API (cont'd.)
• Sometimes users don't notice or ignore geolocation
request
– Request neither fails or succeeds
– Any dependent code not executed
27. JavaScript, Sixth Edition 27
Using the Geolocation API (cont'd.)
Figure 10-10 Flowchart illustrating flow of current geolocation code
28. JavaScript, Sixth Edition 28
Using the Geolocation API (cont'd.)
• Can handle lack of yes/no response from user
– setTimeout() method
– Start countdown before request
• If timeout expires, stop waiting and trigger failure code
• If user responds, cancel timeout
29. JavaScript, Sixth Edition 29
Using the Geolocation API (cont'd.)
Figure 10-11 Flowchart illustrating geolocation code that incorporates setTimeout()
30. JavaScript, Sixth Edition 30
Using the Geolocation API (cont'd.)
• Code complete to acquire geolocation information
– Then you can integrate with databases
• Using the Google Maps API
– Can display a map centered on user's location
– Can show route/directions between two locations
– Includes 2 constructors
• Map() creates a map object
var name = new google.maps.Map(element, options);
• LatLng() creates an object containing coordinates
center: new google.maps.LatLng(latitude, longitude)
31. JavaScript, Sixth Edition 31
Using the Geolocation API (cont'd.)
• Using the Google Maps API (cont'd.)
– Example—create new map centered on current
position with zoom of 11:
var currPosLat = position.coords.latitude;
var currPosLng = position.coords.longitude;
var mapOptions = {
center: new google.maps.LatLng(currPosLat, currPosLng),
zoom: 11
};
var map = new google.maps.Map(document.getElementById("map"),↵
mapOptions);
32. JavaScript, Sixth Edition 32
Using the Geolocation API (cont'd.)
• Using the Google Maps API (cont'd.)
– Can also create map centered on specified point
– Geocoding
• Converting physical address to latitude/longitude
coordinates
33. JavaScript, Sixth Edition 33
Using the Battery Status API
• Adds a battery property to Navigator object
Table 10-11 Events of the battery object
Table 10-10 Properties of the battery object
34. JavaScript, Sixth Edition 34
Using the Device Orientation API
• Provides access to changes in position and speed
– Gyroscope
• Device hardware that detects orientation in space
• deviceorientation event
– alpha, beta, and gamma coordinate properties
– Accelerometer
• Device hardware that detects changes in speed
• devicemotion event
– reports values for acceleration and rotation
35. JavaScript, Sixth Edition 35
Using the WebRTC API
• Short for web real-time communication
• Enables apps to
– receive data from device camera and microphone
– send and receive audio/video/data in real time
• Should eventually allow text/video chat using only
HTML and JavaScript
36. JavaScript, Sixth Edition 36
Enhancing Mobile Web Apps
• Testing tools
– Often impractical to collect many mobile devices
– Online services available for testing
– Free testing apps from mobile OS makers:
Table 10-12 Software used to simulate mobile devices
37. JavaScript, Sixth Edition 37
Enhancing Mobile Web Apps (cont'd.)
• Minimizing Download Size
– Mobile speeds usually slower
– Mobile users often have data caps
38. JavaScript, Sixth Edition 38
Enhancing Mobile Web Apps (cont'd.)
• Minimizing Download Size (cont'd.)
– Loading Scripts Responsively
Figure 10-14 Implementing responsive script loading for oaktop.htm
39. JavaScript, Sixth Edition 39
Enhancing Mobile Web Apps (cont'd.)
• Minifying Files
– Removes comments, indents, and line breaks
– Tweaks code in other ways to make it smaller
– Online minifying services available
40. JavaScript, Sixth Edition 40
Summary
• Touch events focus on responding to a user's finger
touches on a touchscreen
• To ensure OS interface doesn't respond to gestures
– Use the preventDefault() method
• Pointer events are different than touch events
– Aim to handle input from mouse, finger, or stylus
• Geolocation API provides access to a user's latitude
and longitude coordinates
• A number of tools exist for testing mobile web apps
virtually
41. JavaScript, Sixth Edition 41
Summary (cont'd.)
• Important to minimize download size of mobile web
app
– Load scripts responsively
– Minify files