Also watch out for the useful handlers like, onfullscreenchange: An event handler for the fullscreenchange event. onfullscreenerror: An event handler for the fullscreenerror event.
async function performCopy(event) { event.preventDefault(); try { await navigator.clipboard.writeText(copyText); console.log(`${copyText} copied to clipboard`); } catch (err) { console.error('Failed to copy: ', err); } }
async function performPaste(event) { event.preventDefault(); try { const text = await navigator.clipboard.readText(); setPastetext(text); console.log('Pasted content: ', text); } catch (err) { console.error('Failed to read clipboard contents: ', err); } }
Resize Observer API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
useEffect(() => { try { let dumbBtn = document.getElementById('dumbBtnId'); var resizeObserver = new ResizeObserver(entries => { for(const entry of entries) { // Get the button element and color it // based on the range values like this, entry.target.style.color = 'green`; } }); resizeObserver.observe(dumbBtn); } catch(e) { setSupported(false); console.log(e); } }, [rangeValue]);
const videoOff = () => { track.stop(); } Also watch out for the methods,
getPhotoCapabilities(): To get the ranges of available configuration options. getPhotoSettings(): To get the current photo configuration settings.
Broadcast Channel API
The Broadcast Channel API allows communication between browsing contexts (windows, tabs, iframes) and workers on the same origin.
1 2 3 4 5 6 7 8 9 10 11 12 13
const CHANNEL_NAME = "channel"; const bc = new BroadcastChannel(CHANNEL_NAME); const message = 'I am wonderful!'; const sendMessage = () => { bc.postMessage(message); }
const CHANNEL_NAME = "channel"; const bc = new BroadcastChannel(CHANNEL_NAME); bc.addEventListener('message', function(event) { console.log(`Received message, "${event.data}", on the channel, "${CHANNEL_NAME}"`); });
Performance Interface API
The Performance interface provides access to the three major APIs