Skip to content

Instantly share code, notes, and snippets.

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@LearningNerd
LearningNerd / helper.js
Last active July 10, 2024 10:43
Using import/export for front-end modules, example 1
export function helper(x) {
console.log(x);
}
@VehpuS
VehpuS / touchmove-mouseover-simulation.md
Last active July 3, 2024 13:01
Simulating Javascript mouseover events on touch screens using touchmove attributes and document.elementFromPoint

I made an HTML port of game of life made with a table of checkboxes based on Pluralsight's Play by Play: HTML, CSS, and JavaScript with Lea Verou (http://www.pluralsight.com/courses/play-by-play-lea-verou). I was able to create a cool mousedown interface that allowed the "player" to draw on the board by dragging the mouse while it was down, and wanted to do the same for touch devices.

Unfortunately, touch events only hold references to the DOM element where they began (i.e. where "touchstart" fired) and do not recognize the DOM elements that exist under them (a detailed explanation for this can be found here: http://stackoverflow.com/questions/4550427/prefered-alternative-to-onmouseover-for-touch).

Instead, touch events maintain several lists of Touch objects - which represent interactions with the touch screen. Among these objects' properties are clientX and clientY, which indicate the X and Y coordinates of the events relative to the viewport (go to http://www.javascriptkit.com/javatutors/touchevents.shtm