Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@LoyEgor
LoyEgor / detect-mobile.js
Created July 10, 2018 15:19
detect all kinds of mobile devices (userAgent)
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
LoyEgor / custom.js
Last active July 17, 2018 21:31
check end of transition animation and prevent start twice
// check transitions end
function whichTransitionEvent() {
var t,
el = document.createElement("fakeelement");
var transitions = {
"transition": "transitionend",
"OTransition": "oTransitionEnd",
"MozTransition": "transitionend",
"WebkitTransition": "webkitTransitionEnd"
@LoyEgor
LoyEgor / gulpfile.js
Last active December 26, 2020 22:56
batch images (resize and compress)
// 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
LoyEgor / gulpfile.js
Created January 8, 2018 14:31
inject css inline
//install
//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
LoyEgor / gulpfile.js
Last active March 18, 2021 07:25
inject js as async (custom way)
//install
//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
}), {
/* 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
LoyEgor / cross.less
Created June 25, 2017 14:21
style for close icon
&:after,
&:before {
content: '';
@s: 2px;
width: 100%;
height: @s;
background-color: @brandcol1;
display: block;
position: absolute;
left: 0;
@LoyEgor
LoyEgor / macos-font.css
Created June 24, 2017 18:06
normalize fonts for macos
html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@LoyEgor
LoyEgor / media.less
Created June 24, 2017 18:01
media with nubers
@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
LoyEgor / gulpfile.js
Last active March 18, 2021 07:28
gulp-less + cust-error-msg + browserSync + compress {js,css,img,html}
//install
// 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');