JSFiddle - React, Tailwind, and code Playground

by mohayonao

HTML

<span id="text"></span>

JavaScript

$(function() {
  "use strict";

  function startSound() {
    $("#text").text("new Noise().start('+0', 1.5)");
  }

  var ua = window.navigator.userAgent;
  if (/iphone|ipad|android/i.test(ua)) {
    var touchstart = function() {
      document.body.removeEventListener("touchstart", touchstart, false);
      startSound();
    };
    document.body.addEventListener("touchstart", touchstart, false);
    $("#text").text("addEventListener 'touchStart'");
  } else {
    $("#text").text("setTimeout(startSound, 0)");
  }

});