Skip to content

Instantly share code, notes, and snippets.

View alexko30's full-sized avatar

Alexandr Kornienko alexko30

  • Kiev, Ukrane
View GitHub Profile
interpolate(startValue, destValue, progress, data) {
const r = lerp(startValue.color[0], destValue.color[0], progress);
const g = lerp(startValue.color[1], destValue.color[1], progress);
const b = lerp(startValue.color[2], destValue.color[2], progress);
const a = lerp(startValue.valpha, destValue.valpha, progress);
const color = Color.rgb(r, g, b, a)[data.format === 'rgba' ? 'rgb' : data.format]();
return typeof color === 'string' ? color : color.string();
}
initialize(startValue, destValue) {
return {
data: {
format: (startValue.indexOf('rgba') >= 0 && 'rgba')
|| (startValue.indexOf('rgb') >= 0 && 'rgb')
|| (startValue.indexOf('#') >= 0 && 'hex')
|| Color(startValue).model
},
startValue: Color(startValue).rgb(),
destValue: Color(destValue).rgb()
test(startValue) { // rgb(255, 0, 0)
return startValue.indexOf('rgb') >= 0
|| startValue.indexOf('#') >= 0
|| startValue.indexOf('hsl') >= 0
|| (typeof startValue === 'string' && colorString.get.rgb(startValue)); // true
}
const state = document.querySelector('#tweeningState');
document.querySelector('#playPauseButton')
.addEventListener('click', toggle());
let between = new Between(0, 400)
.time(2000)
.on('pause', () => {
state.innerText = 'state: paused';
}).on('play', () => {
new Between('red', 'rgb(255,40,30)')... // return rgb
new Between('red', 'green')... // return rgb
new Between('hsl(57, 100%, 50%)', 'rgb(255,40,30)')... // return hsl
new Between('yellow', 'hsl(57, 100%, 50%)')... // return hsl
./src/between.js → ./build/between.js...
[!] (babel plugin) Error: [BABEL] /Users/alexko/Desktop/dk/Projects/between.js/src/x.js: Invalid Option: 'last 2 versions,safari >= 7' is not a valid value for 'targets.browser'. (While processing: "/Users/alexko/Desktop/dk/Projects/between.js/node_modules/@babel/preset-env/lib/index.js")
src/between.js
Error: [BABEL] /Users/alexko/Desktop/dk/Projects/between.js/src/x.js: Invalid Option: 'last 2 versions,safari >= 7' is not a valid value for 'targets.browser'. (While processing: "/Users/alexko/Desktop/dk/Projects/between.js/node_modules/@babel/preset-env/lib/index.js")
at semverifyTarget (/Users/alexko/Desktop/dk/Projects/between.js/node_modules/@babel/preset-env/lib/targets-parser.js:148:11)
at __default (/Users/alexko/Desktop/dk/Projects/between.js/node_modules/@babel/preset-env/lib/targets-parser.js:154:92)
at Object.keys.filter.sort.reduce (/Users/alexko/Desktop/dk/Projects/between.js/node_modules/@babel/preset-env/lib/targets-parser.js:195:43)
at A
// yarn add --dev eslint prettier eslint-config-airbnb@^15.0.1 eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y@^5.1.1
{
"extends": ["airbnb", "prettier", "prettier/react"],
"plugins": ["prettier"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module",
"ecmaFeatures": {
@alexko30
alexko30 / elemntToTheEnd.js
Last active May 17, 2018 17:26
Moves some elements of the array to the end
function elemntToTheEnd(arr, el) {
let counter = 0, len = arr.length;
for (let i = 0; i < arr.length; i++) {
counter++;
if (arr[i] == el) {
arr.push(arr[i]);
arr.splice(i, 1);
i--;
}
@alexko30
alexko30 / ifDivided.js
Created May 16, 2018 18:43
ifDivided.js
function ifDivided(arr, divider) {
let flag = false;
for (let i = 0; i < arr.length; i++) {
if (arr[i] % divider == 0) {
flag = true;
break;
}
}
@alexko30
alexko30 / scoreWords.js
Created May 16, 2018 18:23
scoreWords.js
function scoreWords(sentence) {
sentence = sentence.split(' ');
let amountOfLetters = 0,
currentCounter = 0,
endCounter = 0,
index;
sentence.forEach((x, i) => {
x.split('').forEach(y => {
currentCounter++