Skip to content

Small patch to fix IE11 issue #2

@lessonpix

Description

@lessonpix

Hi folks, I realize this isn't a high-activity project, but I have been using it (with success) on Chrome on a project and had found it to be flaky on IE (event the latest version 11).

What I found was that IE was providing decimal (non-integer) X/Y coordinates in events on the Canvas and this was throwing off the "Find Index" code. so, here's a quick fix for that (it works on IE11)

`                // e: click event object
                // w: width of canvas element
                // offset: canvas selement offset object
                // returns canvas index
                var canvasIndexFromEvent = function(e,w,offset) {
                        var x = Math.floor(e.pageX) - parseInt(Math.floor(offset.left));
                        var y = Math.floor(e.pageY) - parseInt(Math.floor(offset.top));
                        return Math.floor((x + y * w) * 4);
                };

`

Notice all I did was "floor" the incoming x/y/top/left values and live was good again.

Let me know if this is helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions