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
hypeDocument.syncHypeToAnime = function(anim){ | |
var reverselookup = {'translateX': 'left', 'translateY': 'top'} | |
anim.animations.forEach(function(a){ | |
if (!a.animatable.target.classList.contains('HYPE_element')) return; | |
if (['top','left','translateX', 'translateY', 'width','height','rotateZ','scaleX','scaleY','opacity','z-index'].includes(a.property)){ | |
var hypeProp = reverselookup[a.property] || a.property; | |
hypeDocument.setElementProperty(a.animatable.target, hypeProp, parseFloat(a.currentValue) ); | |
} | |
}); | |
} |
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
anime({ | |
targets: '.circle', | |
translateX: '250px', | |
translateY: '150px', | |
backgroundColor: '#FFF', | |
rotateY: '360deg', | |
rotateX: '360deg', | |
easing: 'easeInOutQuad', | |
changeComplete: function(anim){ |
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
setInterval(function(){ | |
var elm = document.querySelector((Math.random()>0.5)? '#leftKey' : '#rightKey'); | |
elm.click(); | |
}, 100); |
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
/** | |
* Resolve variables in string using a variable lookup | |
* | |
* @param {string} str The string to resolve variables in. | |
* @param {object} variables The variables to resolve. | |
* @returns {string} The resolved string. | |
*/ | |
function resolveVariablesInString(str, variables) { | |
if (typeof str === 'string') { | |
var matches = str.match(/\${.*?}|%{.*?}|✨{.*?}/g); |
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
/** | |
* Converts a key and value to a string. | |
* | |
* @param {strin} key | |
* @param {string|number|boolean|object|function} value | |
* @param {string} indent | |
* @return {string} | |
*/ | |
function keyToString(key, value, indent) { |
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 scrollSpeed = 0; | |
var isScrolling = false; | |
document.addEventListener('keydown', function(e) { | |
if (sidebar.classList.contains('open')) { | |
if (e.shiftKey && e.keyCode === 38) { | |
scrollSpeed *= 1.5; |
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 selfFullFilling(fn) { | |
let value; | |
return function() { | |
return value || (value = fn.apply(this, arguments)); | |
}; | |
} | |
const add = selfFullFilling(function(a, b) { | |
console.log("calculated!") | |
return a + b; |
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
/** | |
* Extract the comments from a string. | |
* @param {string} str - The string to extract the comments from. | |
* @returns {Array.<string>} - An array of comment strings. | |
*/ | |
function getCommentsFromString(str) { | |
str = str.toString(); | |
var start = str.indexOf("/*"); | |
var end = str.indexOf("*/"); | |
var result = []; |
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
/** | |
* This function creates another function that can be used to loop through a set of steps. | |
* This could be useful, for example, in creating animations or a set of instructions that need to be followed in order. | |
* | |
* @param {Array} arr - The array of steps to be looped through | |
* @param {number} i - The index to start at | |
* @param {function} callback - The function to be called on each step | |
* @param {string} key - The key to use for the object | |
* @returns {function} - A function that can be used to loop through the steps | |
*/ |
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
#!/usr/bin/python | |
# HypeTemplate.hype-export.py | |
# Export Script for Tumult Hype to produce offer a generic template system | |
# | |
# MIT License | |
# Copyright (c) 2022 Max Ziebell | |
# | |
import argparse |