Skip to content

Instantly share code, notes, and snippets.

@SpaceShot
Forked from anonymous/index.html
Created August 26, 2014 19:48
Show Gist options
  • Select an option

  • Save SpaceShot/e418846da3065d77dfa8 to your computer and use it in GitHub Desktop.

Select an option

Save SpaceShot/e418846da3065d77dfa8 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Aug 26, 2014.
    2 changes: 2 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <span id="support">No multi-touch support</span><br>
    <canvas id="drawSurface" width="500px" height="500px" style="border:1px solid black;"></canvas>
    17 changes: 17 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    window.addEventListener('load', function() {
    var canvas = document.getElementById("drawSurface"),
    context = canvas.getContext("2d");
    if (window.navigator.pointerEnabled) {
    canvas.addEventListener("pointermove", paint, false);
    if(window.navigator.maxTouchPoints>1)
    document.querySelector("#support").innerText = "Your hardware supports multi-touch!";
    }
    else {
    //Provide fallback for user agents that do not support Pointer Events
    canvas.addEventListener("mousemove", paint, false);
    }
    function paint(event) {
    if(event.buttons>0)
    context.fillRect(event.clientX, event.clientY, 5, 5);
    }
    });
    3 changes: 3 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    html {
    touch-action: none;
    }
    7 changes: 7 additions & 0 deletions ucnhv.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ucnhv
    -----


    A [Pen](http://codepen.io/anon/pen/ucnhv) by [Captain Anonymous](http://codepen.io/anon) on [CodePen](http://codepen.io/).

    [License](http://codepen.io/anon/pen/ucnhv/license).