This file contains hidden or 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
| const mouseMoveEls = Array.from(document.getElementsByClassName('transform__mm')); | |
| document.addEventListener( 'mousemove', (e) => { | |
| const width = window.outerWidth; | |
| const height = window.outerHeight; | |
| const offsetX = 0.5 - e.pageX / width; | |
| const offsetY = 0.5 - e.pageY / height; | |
| mouseMoveEls.forEach((el, i) => { | |
| const dataOffset = parseInt(el.getAttribute('data-offset')); | |
| const translate = `translate3d(${Math.round(offsetX * dataOffset)}px, ${Math.round(offsetY * dataOffset)}px, 0px)`; |
This file contains hidden or 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 onWindowResize() { | |
| windowHalfX = window.innerWidth / 2; | |
| windowHalfY = window.innerHeight / 2; | |
| camera.aspect = window.innerWidth / window.innerHeight; | |
| camera.updateProjectionMatrix(); | |
| renderer.setSize( window.innerWidth, window.innerHeight ); | |
| } | |
| window.addEventListener( 'resize', onWindowResize, false ); |
This file contains hidden or 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
| let fn; | |
| (fn = () => { | |
| })(); | |
| fn(); |
This file contains hidden or 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
| /** | |
| * Retrieve parameter values from URL | |
| * @param {name} name of paramater | |
| * @param {url} URL to fetch parameter from | optional | |
| * @returns URL param value || null | |
| */ | |
| const getURLParemeters = ( name, url ) => { | |
| if (!url) url = location.href; | |
| name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
| var regexS = "[\\?&]"+name+"=([^&#]*)"; |
This file contains hidden or 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
| width: 200px; | |
| text-overflow: ellipsis; | |
| overflow: hidden; | |
| white-space: nowrap; |
This file contains hidden or 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
| const scrollToItemId = (containerId, srollToId) => { | |
| const scrollContainer = document.getElementById(containerId); | |
| const item = document.getElementById(scrollToId); | |
| //with animation | |
| const from = scrollContainer.scrollTop; | |
| const by = item.offsetTop - scrollContainer.scrollTop; | |
| if (from < item.offsetTop) { | |
| if (item.offsetTop > scrollContainer.scrollHeight - scrollContainer.clientHeight) { | |
| by = (scrollContainer.scrollHeight - scrollContainer.clientHeight) - scrollContainer.scrollTop; |
This file contains hidden or 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
| const mapTree = (node,mapper) => { | |
| return { | |
| value: mapper(node.value), | |
| nodes: node.nodes | |
| ? node.nodes.map( x => | |
| mapTree(x, mapper) | |
| ) | |
| : null | |
| } | |
| } |
This file contains hidden or 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 (!Array.prototype.includes) { | |
| Array.prototype.includes = function(searchElement /*, fromIndex*/) { | |
| 'use strict'; | |
| if (this == null) { | |
| throw new TypeError('Array.prototype.includes called on null or undefined'); | |
| } | |
| var O = Object(this); | |
| var len = parseInt(O.length, 10) || 0; | |
| if (len === 0) { |
This file contains hidden or 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
| // Listen for ambient lighting in room | |
| window.addEventListener('devicelight', (e) => { | |
| console.log(`${e.value} lux`); | |
| }); |
This file contains hidden or 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
| const localStorageMiddleware = store => next => action => { | |
| if (action.type === REGISTER || action.type === LOGIN) { | |
| if (!action.error) { | |
| window.localStorage.setItem('jwt', action.payload.user.token); | |
| agent.setToken(action.payload.user.token); | |
| } | |
| } else if (action.type === LOGOUT) { | |
| window.localStorage.setItem('jwt', ''); | |
| agent.setToken(null); | |
| } |
OlderNewer