Skip to content

Instantly share code, notes, and snippets.

LoyEgor / detect-mobile.js
Created Jul 10, 2018
detect all kinds of mobile devices (userAgent)
View detect-mobile.js
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|k
LoyEgor / custom.js
Last active Jul 17, 2018
check end of transition animation and prevent start twice
View custom.js
// check transitions end
function whichTransitionEvent() {
var t,
el = document.createElement("fakeelement");
var transitions = {
"transition": "transitionend",
"OTransition": "oTransitionEnd",
"MozTransition": "transitionend",
"WebkitTransition": "webkitTransitionEnd"
LoyEgor / gulpfile.js
Last active Dec 26, 2020
batch images (resize and compress)
View gulpfile.js
// install
// cd node_modules \
// chmod -R a+rwX .
// run without sudo
// npm i gulp-responsive --unsafe-perm
// npm i del gulp psd2png color
// npm i gulp-imagemin imagemin-pngquant imagemin-zopfli imagemin-mozjpeg imagemin-giflossy -f
LoyEgor / gulpfile.js
Created Jan 8, 2018
inject css inline
View gulpfile.js
//npm i gulp-inject group-array@0.3.1
var inject = require('gulp-inject');
// inject cssinlining
gulp.task('inject:cssinlining', function() {
return gulp.src('./app/*.html')
.pipe(inject(gulp.src('app/css/header.min.css'), {
starttag: '<!-- inject:cssinlining -->',
transform: function(filePath, file) {
LoyEgor / gulpfile.js
Last active Mar 18, 2021
inject js as async (custom way)
View gulpfile.js
//npm i gulp-inject group-array@0.3.1
var inject = require('gulp-inject');
//inject libs js
gulp.task('inject:js', function() {
return gulp.src('./app/*.html')
.pipe(inject(gulp.src('./app/js/libs.min.js', { //inject more than one js in capturedbyanastasiia
read: false //just inject no read
}), {
View font.less
/* fonts var */
@fdir: '../fonts/';
@ff-name: AvenirNextCyr CirceRoundedAlt;
@ff-style-1: Regular Bold BoldItalic;
@ff-style-2: Regular Bold;
@ff-count: length(@ff-name);
/* set to none if no need. Then use .ff(n,n) where first n - number of font, second for style of font */
@ff-name-short: av ci;
@ff-style-1-short: rg bd bdi;
@ff-style-2-short: rg bd;
LoyEgor / cross.less
Created Jun 25, 2017
style for close icon
View cross.less
&:before {
content: '';
@s: 2px;
width: 100%;
height: @s;
background-color: @brandcol1;
display: block;
position: absolute;
left: 0;
LoyEgor / macos-font.css
Created Jun 24, 2017
normalize fonts for macos
View macos-font.css
html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
LoyEgor / media.less
Created Jun 24, 2017
media with nubers
View media.less
@max1200: ~"(max-width: 1199px)";
@max992: ~"(max-width: 991px)";
@max768: ~"(max-width: 767px)";
@max320: ~"(max-width: 320px)";
@min1200: ~"(min-width: 1200px)";
@min992: ~"(min-width: 992px)";
@min768: ~"(min-width: 768px)";
@min320: ~"(min-width: 321px)";
@992to1200: @min992 and @max1200;
@768to992: @min768 and @max992;
LoyEgor / gulpfile.js
Last active Mar 18, 2021
gulp-less + cust-error-msg + browserSync + compress {js,css,img,html}
View gulpfile.js
// npm i gulp-autoprefixer browser-sync gulp-cache gulp-clean-css gulp-concat del gulp gulp-if gulp-util gulp-htmlmin gulp-imagemin imagemin-giflossy imagemin-mozjpeg imagemin-pngquant imagemin-zopfli gulp-less gulp-notify gulp-plumber gulp-replace gulp-sourcemaps gulp-uglify -f
// node node_modules/jpegtran-bin/lib/install.js
// node node_modules/gifsicle/lib/install.js
// node node_modules/zopflipng-bin/lib/install.js
// node node_modules/mozjpeg/lib/install.js
// node node_modules/giflossy/lib/install.js
// node node_modules/pngquant-bin/lib/install.js
var autoprefixer = require('gulp-autoprefixer');