File | Diff | branch-name |
branch-with-a-long-name |
Event |
---|
This file contains 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
// http://stackoverflow.com/questions/21961839/simulation-background-size-cover-in-canvas | |
function drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) { | |
if (arguments.length === 2) { | |
x = y = 0; | |
w = ctx.canvas.width; | |
h = ctx.canvas.height; | |
} | |
// default offset is center | |
offsetX = typeof offsetX === "number" ? offsetX : 0.5; |
This file contains 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
/* | |
href | |
┌────────────────────────────────────────┴──────────────────────────────────────────────┐ | |
origin │ | |
┌────────────┴──────────────┐ │ | |
│ authority │ | |
│ ┌───────────────┴───────────────────────────┐ │ | |
│ │ host resource | |
│ │ ┌──────────┴─────────────────┐ ┌────────────┴───────────┬───────┐ | |
│ │ hostname │ pathname │ │ |
This file contains 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 { urlToFileSystemPath } from "@jsenv/filesystem" | |
import { require } from "@jsenv/core/src/internal/require.js" | |
export const createMagicSource = ({ url, content, sourcemap }) => { | |
if (content === undefined) { | |
throw new Error("content missing") | |
} | |
const filename = urlToFileSystemPath(url) | |
const { |
This file contains 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
const bubbleIframeEvents = (iframe, document) => { | |
const iframeWindow = iframe.contentWindow | |
iframeWindow.addEventListener( | |
'mousemove', | |
(event) => { | |
const boundingClientRect = iframe.getBoundingClientRect() | |
const fakeEvent = new CustomEvent( | |
'mousemove', | |
{ |
This file contains 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
document.querySelector('button').onclick = () => { | |
const scrollStart = document.querySelector(".menu-wrapper").scrollLeft | |
const scrollEnd = scrollStart + menuWrapperSize | |
startJavaScriptAnimation({ | |
duration: 300, | |
onProgress: ({ progress }) => { | |
document.querySelector(".menu-wrapper").scrollLeft = | |
scrollStart + (scrollEnd - scrollStart) * progress | |
}, | |
}) |
This file contains 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 const createSignal = () => { | |
let listeners = [] | |
const listen = (callback) => { | |
let removed = false | |
listeners = [...listeners, callback] | |
return () => { | |
if (removed) return | |
removed = true | |
const listenersWithoutCallback = [] |
This file contains 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
<html> | |
<head> | |
<title>Redux stuff</title> | |
</head> | |
<body> | |
<main> | |
<iframe src="./without-redux.html"></iframe> | |
<iframe src="./with-redux.html"></iframe> | |
</main> | |
<style> |
This file contains 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
const debounce = ( | |
fn, | |
{ debounceInterval = 50, maxConcurrentRequests = 15, unstackCount = 10 } = {}, | |
) => { | |
let queue = [] | |
let pendingCount = 0 | |
const debouncedFn = async (request) => { | |
let entry | |
const promise = new Promise((resolve, reject) => { | |
entry = { request, resolve, reject } |
This file contains 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
const composeProps = (leftProps, rightProps) => { | |
const composedProps = { ...rightProps } | |
Object.keys(leftProps).forEach((key) => { | |
const leftValue = leftProps[key] | |
if (key in rightProps) { | |
const rightValue = rightProps[key] | |
composedProps[key] = composeProp(leftValue, rightValue) | |
} else { | |
composedProps[key] = leftValue |
NewerOlder