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
// determine if in-browser or using node.js | |
// thruthy | |
var _nodejs = ( | |
typeof process !== 'undefined' && process.versions && process.versions.node); | |
if (_nodejs) { | |
_nodejs = { | |
version: process.versions.node | |
}; | |
} |
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 { useSlots } from 'vue'; | |
export default function useHasSlot() { | |
const slots = useSlots(); | |
return function hasSlot(name) { | |
return slots[name] && !isEmptySlot(slots[name]()); | |
}; | |
} | |
function isEmptySlot(items) { |
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 default function ActiveElementObserver (handler = function () {}) { | |
let prev; | |
let raf; | |
this.observe = _ => { | |
cancelAnimationFrame(raf); | |
raf = undefined; | |
if (document.activeElement !== prev) { | |
handler({ activeElement: document.activeElement, prev }); | |
prev = document.activeElement; |
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
function dfStripScripts = function(data, type) | |
{ | |
// incase the response is full html with scripts remove them | |
type = type || 'text'; | |
if(type=='html'||type=='text'){ | |
/*return data.replace(/<script.*>.*?<\/script>/gi, '');*/ | |
return data.replace(/<script.*?>([\w\W\d\D\s\S\0\n\f\r\t\v\b\B]*?)<\/script>/gi, ''); | |
} | |
return data; | |
}; |
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
function Looper(update, targetFPS = 30, autoplay = true) { | |
let updating = false; | |
this.autoplay = autoplay; | |
this.targetFPS = targetFPS; | |
const advanceFrame = () => { | |
updating = true; | |
const next = () => { | |
const delay = this.autoplay ? 1000 / (this.targetFPS || 30) : 0; | |
setTimeout(() => updating = false, delay); |
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
dat.GUI.prototype.convertToDisplay = function(owner, property) { | |
var field = this.__controllers.find(function(item){return item.property === property}); | |
var parent = field.domElement.parentElement; | |
var value = owner[property]; | |
delete owner[property]; | |
Object.defineProperty(owner, property, { | |
get: function() { | |
return value; | |
}, | |
set: function(newValue) { |
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
function transformsSupport() { | |
if (!window.getComputedStyle) { | |
return false; | |
} | |
var el = document.createElement('p'), | |
has3d, | |
transformPropName, | |
transforms = { | |
webkitTransform: '-webkit-transform', |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var iso8601Duration = require('iso8601-duration'); | |
// https://github.com/wking/milliseconds-to-iso-8601-duration/blob/master/milliseconds-to-iso-8601-duration.js | |
var millisecondsToISO8601Duration = function(milliseconds) { | |
if (milliseconds == 0) { | |
return 'P0D'; |
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
/* eslint-disable no-console */ | |
const originalConsoleError = console.error; | |
export function restoreConsoleError() { | |
console.error = originalConsoleError; | |
} | |
export function createSuppressedConsoleError(ignoreThese = []) { | |
if (console.error === originalConsoleError) { | |
console.error = (...args) => { |
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
/** | |
* @author Rhys Burnie | |
* Personal setup for Stats and dat.GUI with a materialColors object for quick nice color options. | |
* (clientside - dirty) - for things like p5 sketches, codepens etc. | |
* | |
* promiseTools().then(function(tools){ | |
* var colors = tools.colors; | |
* var stats = tools.stats; | |
* var gui = tools.gui; | |
* |
NewerOlder