Skip to content

Instantly share code, notes, and snippets.

View prostoandrei's full-sized avatar

Andrei Vaganov prostoandrei

  • Qase
  • Tbilisi, Georgia
View GitHub Profile
@prostoandrei
prostoandrei / deep-merge-objects.js
Last active May 16, 2018 07:37
deepMergeObjects in JavaScript
/**
* Принимает на вход произвольное количество объектов и производит их слияние возвращая новый экземпляр объекта.
* Если на одном уровне находится два массива, то происходит их конкатинация.
*
* @param {Object} objects
* @returns {Object}
*/
export default function deepMergeObjects(...objects) {
const isObject = obj => obj && typeof obj === 'object';
@prostoandrei
prostoandrei / getDocumentScrollBottom.js
Last active May 16, 2018 07:37
Returns document scroll bottom
function getDocumentScrollBottom() {
return document.documentElement.clientHeight + document.documentElement.scrollTop;
}
@prostoandrei
prostoandrei / isElementInViewport.js
Last active March 2, 2018 09:11
Check if element is visible in browser viewport
const isElementInViewport = (el) => {
const rect = el.getBoundingClientRect();
return rect.bottom > 0 && rect.right > 0 &&
rect.left < (window.innerWidth || document.documentElement.clientWidth) &&
rect.top < (window.innerHeight || document.documentElement.clientHeight);
}
@prostoandrei
prostoandrei / 0_reuse_code.js
Created May 30, 2017 05:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@prostoandrei
prostoandrei / .editorconfig
Created January 30, 2016 07:50
editorConfigGlobal
# editorconfig.org
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 2