Skip to content

Instantly share code, notes, and snippets.

View mauskin's full-sized avatar

Kirill Myshkin mauskin

View GitHub Profile
@mauskin
mauskin / bare-drag-no-drop.js
Last active May 26, 2025 15:41
Minimal cross-browser drag with no drop function
// The most bare cross-browser drag with no drop function I could do.
// Example:
//
// make_draggable(
// thing,
// () => console.log("let’s go"),
// (event) => {
// console.log(event.clientX, event.clientY);
// element.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`;
@mauskin
mauskin / XMLWriter-functions.md
Last active October 29, 2021 13:55
XMLWriter Functions Organized by What They Do

openMemory — Create new xmlwriter using memory for string output
openUri — Create new xmlwriter using source uri for output

setIndentString — Set string used for indenting
setIndent — Toggle indentation on/off

startDocument — Create document tag
endDocument — End current document

text — Write text

@mauskin
mauskin / doOnNextClick.js
Last active June 22, 2021 08:10
Runs a callback on next click and prevents anything else from happening. Helpful for dismissing full viewport banners by clicking anywhere.
function doOnNextClickButNothingElse(callback) {
window.addEventListener(
"click",
function (event) {
event.stopPropagation();
callback();
},
{
capture: true,
once: true