Skip to content

Instantly share code, notes, and snippets.

View zepster's full-sized avatar
🏠
Working from home

Aleksey Smirnov zepster

🏠
Working from home
View GitHub Profile
@zepster
zepster / index.js
Created July 29, 2019 19:06
плавный скролл, requestAnimationFrame scroll, element scroll
const DIRECTIONS = {
TOP: 'top',
BOTTOM: 'bottom',
};
// анимация
const linear = t => t;
const scrollElement = (scrollParams) => {
// что скролим
@zepster
zepster / index.js
Created June 29, 2019 15:19
latest promise
const promiseLatest = (promiseFunction) => {
let lastPromise = null;
const ifDo = (condition, action) => data => condition() && action(data);
const processingPromiseHandler = scopedPromise => (resolve, reject) => scopedPromise
.then(ifDo(() => scopedPromise === lastPromise, resolve))
.catch(ifDo(() => scopedPromise === lastPromise, reject));
return (...args) => {
lastPromise = promiseFunction(...args);
return new Promise(processingPromiseHandler(lastPromise));
};
@zepster
zepster / index.js
Created April 16, 2018 17:52
date range
const Moment = require('moment');
const MomentRange = require('moment-range');
require('moment-recur');
export const moment = MomentRange.extendMoment(Moment);
export const DAY_SLOT = 'day'
export const HOUR_SLOT = 'hour'
export const SECOND_SLOT = 'second'
@zepster
zepster / colors-css.js
Last active February 10, 2018 09:09
css colors hash, hex, class
export default {
primary: {
'primary-800': '#1565C0',
'primary-700': '#1976D2',
'primary-600': '#1E88E5',
'primary-500': '#2196F3',
'primary-400': '#42A5F5',
'primary-300': '#64B5F6',
},
danger: {