Skip to content

Instantly share code, notes, and snippets.

View dhinesh03's full-sized avatar

Dhinesh Kumar dhinesh03

  • ZoomRx
  • London
  • 08:07 (UTC +01:00)
View GitHub Profile
@dhinesh03
dhinesh03 / svelte-mouse-coordination.js
Last active August 11, 2021 16:14
Svelte- sample code to capture mouse coordinates
<script>
let m = { x: 0, y: 0 };
function handleMousemove(event) {
m.x = event.clientX;
m.y = event.clientY;
}
</script>
<div on:mousemove={handleMousemove}>
@dhinesh03
dhinesh03 / capture-mouse-coordination.js
Created August 11, 2021 16:07
React Hook - sample code to capture mouse coordinates
import React, { useState, useCallback, useEffect, useRef } from 'react';
function useEventListener(eventName, handler, element = window) {
// Create a ref that stores handler
const savedHandler = useRef();
// Update ref.current value if handler changes.
// This allows our effect below to always get latest handler ...
// ... without us needing to pass it in effect deps array ...
// ... and potentially cause effect to re-run every render.
@dhinesh03
dhinesh03 / multi-tenancy.js
Last active August 29, 2015 14:20
multi-tenancy workaround for mithril.js
var z = (function (){
//helpers
var cache = {};
var target;
var type = {}.toString;
var noop = function() {};
var retainer = { subtree : 'retain' };
var treeNode = (function() {
treeNode=function(parent,componentName){
this.cName=componentName;
/*****************************************
/* DOM touch support module
/*****************************************/
(function(document) {
var TAPTRESHOLD = 200, // time within a double tap should have happend
TAPPRECISION = 60 / 2, // distance to identify a swipe gesture
touch = { },
tapCount = 0, // counts the number of touchstart events
tapTimer = 0, // timer to detect double tap
isTouchSwipe = false, // set to true whenever
@dhinesh03
dhinesh03 / ember-latest.js
Last active December 16, 2015 05:49
Ember, Ember-Touch and Mobiscroll
// Version: v0.9.8.1-452-gdca2ca4
// Last commit: dca2ca4 (2012-06-27 08:36:22 -0700)
(function() {
/*global __fail__*/
if ('undefined' === typeof Ember) {
Ember = {};