This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
export default function useWindowSize() { | |
const [windowWidth, setWindowWidth] = useState(0); | |
const [windowHeight, setWindowHeight] = useState(0); | |
useEffect(() => { | |
function updateSize() { | |
setWindowWidth(window.innerWidth); | |
setWindowHeight(window.innerHeight); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
export default function useWindowScroll() { | |
const [windowScrollX, setWindowScrollX] = useState(0); | |
const [windowScrollY, setWindowScrollY] = useState(0); | |
useEffect(() => { | |
function updateWindowScroll() { | |
setWindowScrollX(window.scrollX); | |
setWindowScrollY(window.scrollY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
export default function useDeviceOrientation() { | |
const [absolute, setAbsolute] = useState(0); | |
const [alpha, setAlpha] = useState(0); | |
const [beta, setBeta] = useState(0); | |
const [gamma, setGamma] = useState(0); | |
useEffect(() => { | |
function updateDeviceOrientation(e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
export default function useCursorPosition() { | |
const [cursorPositionX, setCursorPositionX] = useState(0); | |
const [cursorPositionY, setCursorPositionY] = useState(0); | |
useEffect(() => { | |
function updateCursorPosition(e) { | |
setCursorPositionX(e !== undefined ? e.clientX : 0); | |
setCursorPositionY(e !== undefined ? e.clientY : 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function modulate( | |
input, | |
[inputRangeInitial, inputRangeFinal], | |
[outputRangeInitial, outputRangeFinal], | |
limit | |
) { | |
const constrain = (result, low, high) => | |
Math.max(Math.min(result, high), low); | |
const result = | |
((input - inputRangeInitial) / (inputRangeFinal - inputRangeInitial)) * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
import "./styles.css"; | |
const data = [ | |
{ id: 1, name: "Marco" }, | |
{ id: 2, name: "Lincoln" }, | |
{ id: 3, name: "Aya" } | |
]; | |
export default function App() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53); | |
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19); | |
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22); | |
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06); | |
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035); | |
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335); | |
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94); | |
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1); | |
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from "react"; | |
import { Keyboard, TextInput, Dimensions } from "react-native"; | |
const Example = () => { | |
const [heightDefined, setHeightDefined] = useState(100); | |
useEffect(() => { | |
Keyboard.addListener("keyboardDidShow", (e) => { | |
setHeightDefined( | |
Dimensions.get("window").height - e.endCoordinates.height |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2020-10-13T20:14:34.045Z","extensionVersion":"v3.4.3"} |