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
/** | |
* 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
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
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
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
if ( hypeDocument.currentDirectionForTimelineNamed(event.timelineName) == hypeDocument.kDirectionForward) { | |
hypeDocument.pauseTimelineNamed(event.timelineName); | |
} |
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
/** | |
* Remove phyics elements from the regular Matter.js collision group | |
* | |
* @param {Nodelist} targetElms The target elements to remove | |
*/ | |
hypeDocument.disablePhysicsCollisions = function(targetElms) { | |
targetElms.forEach(function(elm){ | |
var elmBody = hypeDocument.getElementProperty(elm, 'physics-body'); | |
if (elmBody) elmBody.collisionFilter = { 'group': -1} | |
}); |
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
/** | |
* Query intersections between elements using Matter.js | |
* | |
* @param {Node} sourceElm The source element used in each check | |
* @param {Nodelist} targetElms The target elements to query against | |
* @return {Nodelist} Returns a list of targetElms that intersect with sourceElm | |
*/ | |
hypeDocument.queryIntersections = function(sourceElm, targetElms) { | |
var sourceBody = hypeDocument.getElementProperty(sourceElm, 'physics-body'); | |
if (sourceBody) { |
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
.Product-book .book-section .book-cover .cover-spine-overlay img{ | |
width:100%; | |
display:block; | |
-webkit-box-shadow:0 0 16px rgba(0,0,0,0.5); | |
box-shadow:0 0 16px rgba(0,0,0,0.5) | |
} | |
.Product-book .book-section .book-cover .cover-spine-overlay:after{ | |
position:absolute; | |
content:""; | |
width: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
function symbolInitTest (hypeDocument, element, event){ | |
console.log('HypeSymbolInit'); | |
var symbolInstance = hypeDocument.getSymbolInstanceForElement(element); | |
// do your stuff… | |
} | |
window.HYPE_eventListeners.push({"type":"HypeSymbolInit", "callback":symbolInitTest}); |