This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
export default function() { | |
let [frameTimeState, setFrameTimeState] = useState({ | |
fps: 0, | |
// better use performance.now() | |
// but some static generators like gatsby | |
// might have problems with that | |
lastStamp: Date.now(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
export default function({isDone = false}) { | |
let [startDate] = useState(new Date()); | |
let [newDate, setNewDate] = useState(new Date()); | |
useEffect(() => { | |
const timer = !isDone && setTimeout(()=>{ | |
setNewDate(new Date()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const GENERIC_PREFETCH_CALL = "GENERIC_PREFETCH_CALL"; | |
export const GENERIC_FETCH_SUCCESS_CALL = "GENERIC_FETCH_SUCCESS_CALL"; | |
export const GENERIC_FETCH_FAIL_CALL = "GENERIC_FETCH_FAIL_CALL"; | |
export const handleSuccessError = function(response){ | |
return response.status !== 200 ? response.json().then(error => Promise.reject(error)) : response.json(); | |
} | |
export const fetchConstruct = function({ | |
url, // required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// autoprefixer method | |
/// --- | |
/// @access public | |
/// --- | |
/// @param {string|rulename} $ruleName - rule name | |
/// --- | |
/// @param {string|rule} $ruleValue - rule value | |
@mixin autoprefixer($ruleName, $ruleValue) { | |
-ms-#{$ruleName}: $ruleValue; | |
-moz-#{$ruleName}: $ruleValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simpleExtend | |
var extend = function(targetObj, extendWithObj) { | |
'use strict'; | |
for (var key in extendWithObj) { | |
if (extendWithObj.hasOwnProperty(key)) { | |
targetObj[key] = extendWithObj[key]; | |
} | |
} | |
return targetObj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////// EventEmitter tests | |
console.info(" --- TESTING START \n"); | |
//textObjClass | |
var SomeObjClass = function() { | |
'use strict'; | |
var _someObjClass = { | |
events: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* EventEmitterClass gist | |
* | |
* Description: with this class you can add custom events listening/triggering to any custom object | |
* | |
* usage: just inherit/extend your custom object with this class's | |
* | |
* addEventListener(eventName: {String}, callback: {Function}, optional_context: {Object}) | |
* | |
* removeEventListener(eventName: {String} || callback: {Function}, callback: {Function}, removeAllForThisEvent: {Boolean}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var smoothCalcFromTo = (function () { | |
var timer; | |
var easing_pats = { | |
// accelerating from zero velocity | |
'ease_in_quad' : function(time) { return time * time; }, | |
// decelerating to zero velocity | |
'ease_out_quad' : function(time) { return time * (2 - time); }, | |
// acceleration until halfway, then deceleration | |
'ease_in_out_quad' : function(time) { return time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; }, |