Skip to content

Instantly share code, notes, and snippets.

View Rkokie's full-sized avatar

Roger Rkokie

  • Sight & Sound Systems
View GitHub Profile
@Rkokie
Rkokie / LongPressEventHandler.ts
Last active February 28, 2020 10:59
Angular long press events
import {EventEmitter} from '@angular/core';
var DOWN_EVENT = 'pointerdown';
var MOVE_EVENT = 'pointermove';
var UP_EVENT = 'pointerup';
var CANCEL_EVENT = 'pointercancel';
if (!('PointerEvent' in window)) {
DOWN_EVENT = 'touchstart';
MOVE_EVENT = 'touchmove';
@Rkokie
Rkokie / deepClone.ts
Created March 25, 2021 15:44
deepClone class with typescript
export function deepClone<T>(obj: any): T {
if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) {
return obj;
}
const clone = obj instanceof Date ? new Date(obj) : new obj.constructor();
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
obj.isActiveClone = null;