Skip to content

Instantly share code, notes, and snippets.

View mhdSid's full-sized avatar
🔬
Innovating

moeSidani mhdSid

🔬
Innovating
  • Rakuten
  • Tokyo
View GitHub Profile
public fadeInAudioElementVolume (start: number, end: number, duration: number, callback?: Function): void {
const delta: number = end - start;
let startTime: number = null;
let t: number;
let factor: number;
let frame: any;
const tweenLoop: FrameRequestCallback = (time?: number) => {
if (!time) {
time = new Date().getTime();
}
@mhdSid
mhdSid / arrayIterator.ts
Last active November 11, 2018 22:33
Simple & Generic Way to Iterate Backwards & Forwards through an Array
public iterateBackwards (arrayLength: number, index: number): number {
return index = (index <= 0) ? arrayLength - 1 : --index, index;
}
public iterateForwards (arrayLength: number, index: number): number {
return index = (index >= arrayLength - 1) ? 0 : ++index, index;
}
/*
* Usage