Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

945 B
Raw Blame
// A light tap of the phone's vibration motor, where a native app gives one (a version swiped to,
// a long press, a prompt sent). Android browsers have the Vibration API. Safari on an iPhone has
// none, but since iOS 17.4 a click on an `<input type="checkbox" switch>` plays the system's
// switch haptic, so a hidden one is clicked (the method of the MIT `ios-haptics` package, from
// cobalt.tools). Called from a tap or gesture handler; if a later iOS drops it, nothing happens.

export function haptic() {
  try {
    if (navigator.vibrate?.(8)) return;
    const label = document.createElement("label");
    label.ariaHidden = "true";
    label.style.display = "none";
    const input = document.createElement("input");
    input.type = "checkbox";
    input.setAttribute("switch", "");
    label.appendChild(input);
    document.head.appendChild(label);
    label.click();
    label.remove();
  } catch {
    /* no haptics here */
  }
}