Cs420 Week 7-14
Cs420 Week 7-14
Performance
Why performance
A slow site means that you will have less user
engagement.
Example
let's say you accidentally, introduce a
performance issue, that causes your page to
take an extra half second to load. That's just
500 milliseconds.
Network
Render
Compute
Network
Examples
1. www.vu.edu.pk
2. http://playbiolab.com/
3. https://www.eecs.mit.edu/
Touch Interaction
One of the most important factors in an
immersive user experience on a mobile device
is touch interaction. You expect a responsive
interaction from a device that you hold in the
palm of your hand, and with most mobile
screens, your primary pointing device is your
finger.
As a mobile web developer, you need to be
sure that you're building great touch enabled
user devices
Simple rules for touch UI
Rule 1
Do not relay on Hover Effect
10mm X 10 mm
Rule 3
Touch and mouse are not mutually exclusive
Rule 4
Provide Mouse support as well.
Don’t do anything
It is important to understand that you may not
even need to do anything in order to support
touch.
Touch events emulate mouse clicks already,
and the web browser builds in some gestures
like scrolling and zooming.
https://github.com/ftlabs/fastclick
3) Where finally, of course, you can implement
tech support yourself directly, if you consume
the touch events, you won't have this issue.
Supporting Touch
Go to www.caniuse.com
Or go to http://caniuse.com/#feat=touch
Touch Events
touchstart -> mousedown
touchmove -> mousemove
touchend -> mouseup
touchcancel
Touch Events
Source: https://www.w3.org/TR/touch-events/#touchevent-interface
Source: https://www.w3.org/TR/touch-events/#touch-interface
Touch Events are Fired on The
Original Target
Touch events are always delivered to the element
that first received that Touch.
DOM http://www.w3schools.com/js/js_htmldom.asp
Mouse Emulation
Example:
https://webaudiodemos.appspot.com/midi-
synth/
Synthesizer Application
Application Link
https://webaudiodemos.appspot.com/
https://github.com/cwilso/midi-synth
We will Initially start with touch events.
mouseenter pointerenter
mouseleave pointerleave
mouseout pointerout
mouseover pointerover
color
Text
The most common input type
<input type="text">
Email
Entering an email on the standard keyboard is
very difficult. When we use Input Type as email.
We get a @ sign as well as the .com and other
handy buttons to just make entering an email
address as easy as possible.
<input type="email">
Tel
Tel input provides the user with ability to add
the numbers , it provides ability to quickly add
*, # , + signs as well.
<input type="tel">
Number
Number input provides a key board to quickly
add the numbers.
<input type="number">
Date
Date input types makes it very easy to enter
the date on Webpage. Using Calendar can be
little difficult for users
<input type="date">
Date & Time
Entering Date and Time is very Difficult but for
mobile devices, using Date & Time input it
becomes very easy to enter data.
<input type="datetime">
Month
Search
Regular Expression
Validation
For some types like e-mail, there's some basic
validation. But this is not very smart validation.
http://www.w3schools.com/jsref/jsref_obj_re
gexp.asp
Two Important Features
of Input
Two Important Features of Input
There are two more features I wanted to
mention on inputs.
<input type="file"
accept="video/*;capture=camcorder">
<input type="file"
accept="audio/*;capture=microphone">
Drawbacks of Capture
Extension
The first problem is that this feature only
works in mobile, not in desktop. On desktop,
you only get the normal file open dialogue.
Not access to the webcam.
Secondly, the interface is a file open button,
which is hard to style and make look the way
you might want it to.
Third issue is , taking you to a different
application to take a picture or record some
audio, makes it kind of hard to keep a
consistent flow in your application.
Live Input
We can get Live Input, Audio and Video,
directly under our App by using an API called
getUserMedia.
Link:-
https://developer.mozilla.org/en/docs/Web/A
PI/Navigator/getUserMedia
Example
This is a simple example where we just call
getUserMedia, passing some constraints that
say we want video, and then we assign the
resulting stream to a video element in the
page. Of course, this just gives us a rectangle
with live Video Input.
We probably want to do something with it. If
we want to grab Snapshots like if we want to
implement a Camera Application, we can do
this with a canvas context and DrawImage.
Whenever we want to take a Snapshot, we
simply grab the image from the video and we
draw it to the camera with DrawImage.
Of course a canvas in different than an image.
You can't directly copy a canvas and paste it
somewhere else, or download it your hard drive
or post it to your social networks. Or any of the
other typical User flows centered around
images, but it turns out, canvas has a1 handy
function to encode itself as an image. The
canvas toDataURL method.
Here, instead of displaying the canvas itself,
we're copying the canvas contents as a data
earl to the source of an image tag. And if you
want to save these images to the Mobile's local
storage.
Navigator.getUserMedia()
Syntax
navigator.getUserMedia(constraints,
successCallback, errorCallback);
Parameters
Constraints
A MediaStreamConstaints object specifying the
types of media to request, along with any
requirements for each type.
To require a capability, use the
keywords min, max, or exact (a.k.a. min ==
max). The following demands a minimum
resolution of 1280x720
successCallback
When the call succeeds, the function specified
in the successCallback is invoked with
theMediaStream object that contains the media
stream. You may assign that object to the
appropriate element and work with it, as shown
in the following example:
errorCallback
When the call fails, the function specified in the
errorCallback is invokedwith a
MediaStreamError object as its sole argument
Error Description
Permission to use a media device
PermissionDeniedError was denied by the user or the
system.
No media tracks of the type
NotFoundError specified were found that satisfy
the constraints specified.