Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web APIs que você (provavelmente) não sabia que existiam
Search
Zeno Rocha
June 23, 2017
Programming
1
390
Web APIs que você (provavelmente) não sabia que existiam
Presented at JSExperience
Zeno Rocha
June 23, 2017
Tweet
Share
More Decks by Zeno Rocha
See All by Zeno Rocha
The Next Generation of Developer-First Products
zenorocha
1
400
7 Habits of Highly Productive Developers
zenorocha
1
270
7 Hábitos de Desenvolvedores Altamente Produtivos
zenorocha
1
290
What's new in the Liferay Community
zenorocha
0
550
Launching Liferay Projects Faster with WeDeploy
zenorocha
1
440
How Liferay fits into the real of latest technologies
zenorocha
0
380
Estoicismo e JavaScript
zenorocha
3
860
Por que ninguém se importa com seu novo projeto open source?
zenorocha
2
740
Como investir em... você!
zenorocha
1
460
Other Decks in Programming
See All in Programming
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
340
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
260
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
820
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
940
2 週間で Twitter Bot を作ってみた
contour_gara
0
550
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
230
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
250
Site Reliability Engineering for GMO
pyama86
8
1k
Milestoner
bkuhlmann
1
410
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
2
3.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
The Pragmatic Product Professional
lauravandoore
25
5.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Imperfection Machines: The Place of Print at Facebook
scottboms
260
12k
It's Worth the Effort
3n
180
27k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
9
8.3k
Writing Fast Ruby
sferik
621
60k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Transcript
não sabia que existiam web apis que você provavelmente
@zenorocha
None
None
None
None
2008
2008
2009
2009
2010
2010
2011
2011
2012
2012
2013
2013
2014
2014
None
canvas svg geolocation local storage web sockets audio video drag
& drop web rtc
page visibility
Provê uma API que checa se a aba atual está
visível ou não no navegador. page visibility
window.addEventListener('visibilitychange', () => { if (document.hidden) { console.log('Tab is hidden');
} else { console.log('Tab is focused'); } }); page visibility
None
window.addEventListener('visibilitychange', () => { switch(document.visibilityState) { case 'prerender': console.log('Tab is
pre-rendering'); break; case 'hidden': console.log('Tab is hidden'); break; case 'visible': console.log('Tab is focused'); break; } });
caniuse.com/#feat=pagevisibility BROWSER support
onde usar?
None
None
web share
Permite que um site compartilhe algo para um determinado destino.
Pode ser um serviço de sistema, um aplicativo nativo ou outro site. web share
shareButton.addEventListener(‘click', () => { navigator.share({ title: ‘Some Example’, url: window.location.href
}) .then(console.log('Successful share’)) .catch(console.log(error)); }); web share
onde usar?
None
under developm ent BROWSER support
None
state online
Expõe o estado atual de disponibilidade da rede. online state
console.log(navigator.onLine ? 'online' : 'offline') online state
window.addEventListener('offline', networkStatus); window.addEventListener('online', networkStatus); function networkStatus(e) { console.log(e.type); } online
state
caniuse.com/#feat=online-status BROWSER support
None
let type = navigator.connection.type; // ex: bluetooth, cellular, ethernet, wifi
let max = navigator.connection.downlinkMax; // in megabits network info
onde usar?
None
DEVICE orientation
Expõe as coordenadas de orientação física de um dispositivo. device
orientation
device orientation window.addEventListener('deviceorientation', (e) => { console.log(‘Gamma:’, e.gamma); console.log(‘Beta:’, e.beta);
console.log(‘Alpha:’, e.alpha); });
device orientation let logo = document.querySelector(‘img'); window.addEventListener('deviceorientation', (e) => {
let tiltLR = e.gamma; let tiltFB = e.beta; logo.style.transform = `rotate(${tiltLR}deg) rotate3d(1,0,0, ${tiltFB * -1}deg)`; });
caniuse.com/#feat=deviceorientation BROWSER support
onde usar?
None
VIBRATION
Provê acesso ao hardware de vibração de dispositivos móveis. vibration
// Vibrate for 1 second navigator.vibrate(1000); // Vibrate with a
pattern navigator.vibrate([400, 300, 300, 200, 500]); // Turn off vibration navigator.vibrate(0); VIBRATION vibrate wait vibrate wait vibrate
// Super Mario navigator.vibrate([125,75,125,275,200,275,125,75,125,27 5,200,600,200,600]); // Star Wars navigator.vibrate([500,110,500,110,450,110,200,110,170, 40,450,110,200,110,170,40,500]);
// Go Go Power Rangers navigator.vibrate([150,150,150,150,75,75,150,150,150,15 0,450]); VIBRATION h!ps://goo.gl/bX4ZQv
caniuse.com/#feat=vibration BROWSER support
onde usar?
None
None
clipboard copy & paste
Possibilita interação com o clipboard do usuário através de operações
de copiar, cortar e colar. clipboard
None
// 1. User interaction is required let button = document.querySelector('button');
button.addEventListener('click', () => { select(); copy(); }); clipboard
// 2. Programmatically select an element function select() { let
input = document.querySelector('input'); input.focus(); input.setSelectionRange(0, input.value.length); } clipboard
// 3. Copy selected element text function copy() { try
{ document.execCommand('copy'); } catch (err) { console.error(err); } } clipboard
document.addEventListener('copy', (e) => { console.log(e.target.value); }); document.addEventListener('cut', (e) => {
console.log(e.target.value); }); document.addEventListener('paste', (e) => { console.log(e.clipboardData.getData('text/plain')); }); clipboard
None
None
caniuse.com/#feat=clipboard BROWSER support
onde usar?
None
None
light ambient
Expõe dados do sensor que capta a intensidade de luz
de um ambiente. ambient light
window.addEventListener('devicelight', (e) => { console.log(`${e.value} lux`); }); ambient light
None
None
let sensor = new AmbientLightSensor(); sensor.start(); sensor.onchange = (e) =>
{ console.log(e.reading.illuminance); }; sensor.stop(); ambient light sensor
BROWSER caniuse.com/#feat=ambient-light support
onde usar?
None
None
STATUS battery
Permite que uma página web acesse informações sobre a bateria
de um dispositivo. battery status
navigator.getBattery().then((battery) => { console.log(`${battery.level * 100}%`); battery.addEventListener('levelchange', () => {
console.log(`${this.level * 100}%`); }); }); battery status
caniuse.com/#feat=ba!ery-status BROWSER support
onde usar?
None
None
WEBVR
Uma API experimental que trás o mundo de Realidade Virtual
para web usando Oculus Ri" ou Google Cardboard por exemplo. web VR
BROWSER support chromestatus.com/features#webvr
None
shape detection
É capaz de detectar diferentes formas em imagens como rostos,
códigos de barras e até mesmo texto em uma imagem. shape detection
let faceDetector = new FaceDetector(); faceDetector.detect(image).then(faces => { console.log(‘Faces found:’,
faces.length); }).catch((err) => { console.error(err); }); shape detection
None
BROWSER support under developm ent
onde usar?
None
WEB assembly
WebAssembly, ou wasm, é um novo formato binário para desenvolvimento
de aplicações de baixo nível. web assembly
under developm ent BROWSER support
None
gamepad
Permite que páginas web se conectem com controles de video
game via USB. gamepad
window.addEventListener('gamepadconnected', () => { let gp = navigator.getGamepads()[0]; console.log(‘ID:’, gp.id);
console.log(‘Axes:’, gp.axes.length); console.log(‘Buttons:’, gp.buttons.length); }); gamepad
window.addEventListener('gamepadconnected', gameLoop); function gameLoop() { let gp = navigator.getGamepads()[0]; if
(gp.buttons[0].pressed) { console.log('X'); } requestAnimationFrame(gameLoop); } game loop
caniuse.com/#feat=gamepad BROWSER support
None
web components templates custom elements shadow dom html imports
progressive web apps service workers push notifications offline support app
manifest background sync web usb bluetooth
None
Where the magic happens Your comfort zone
obrigado @zenorocha muito