Skip to content

Instantly share code, notes, and snippets.

View xto3na's full-sized avatar

Sergey Ponomarenko xto3na

  • Dnepropetrovsk, Ukraine
View GitHub Profile
@xto3na
xto3na / eslint-disable-next-line
Created September 30, 2017 16:02
eslint-disable-next-line
// eslint-disable-next-line
console.log('value: ', value);
@xto3na
xto3na / Как рассчитать пропорцию уменьшенной картинки
Created August 3, 2017 10:50
Как рассчитать пропорцию уменьшенной картинки
Формула расчета
Все делается в два этапа:
1 - Делим исходную ширину на требуемую ширину;
2 - Получаем требуемую высоту, поделив исходную высоту на результат деления двух ширин (п.1).
Пример. Возьмем уже всем известные размеры изображений: 1024x768 и 800x600. Представим, что мы не знаем высоту второй картинки. По формуле получается следующее: 768/(1024/800) = 600. Это и есть требуемая нам высота.
Если же мы знаем высоту, а нам нужно получить ширину, то необходимо проделать все, как в первой формуле, только наоборот.
@xto3na
xto3na / swipeHandler
Created August 2, 2017 06:59
swipeHandler
function swipeHandler () {
var initialPoint;
var finalPoint;
document.addEventListener('touchstart', function(event) {
if (typeof event !== 'undefined' && $(event.target).hasClass('slide-img') && $('body').hasClass('mobile')){
initialPoint=event.changedTouches[0];
} else {
return false;
}
}, false);
@xto3na
xto3na / Video background
Last active May 26, 2017 06:39
Video background
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 видео в качестве заднего фона</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<video autoplay loop muted poster="video.jpg" class="bgvideo" id="bgvideo">
<source src="video.mp4" type="video/mp4"></source>
@xto3na
xto3na / Calc in LESS
Created May 24, 2017 09:20
Calc in LESS
max-height: calc(~'100vh - 200px');
@xto3na
xto3na / Paddings and margins helpers generate in SCSS
Created April 11, 2017 06:23
Paddings and margins helpers generate in SCSS
@for $i from 0 through 50 {
.mt-#{$i} {
margin-top: #{$i}px !important;
}
}
@for $i from 0 through 50 {
.mb-#{$i} {
margin-bottom: #{$i}px !important;
}
}
@xto3na
xto3na / Paddings and margins helpers generate in LESS
Last active April 11, 2017 06:24
Paddings and margins helpers generate in LESS
.interval-generator(@index: 0) when (@index <= 50) {
// Paddings with step 5px
.pt@{index} {
padding-top: ~"@{index}px";
}
.pb@{index} {
padding-bottom: ~"@{index}px";
}
.pl@{index} {
@xto3na
xto3na / Regexp for price from text
Last active February 19, 2017 14:03
Regexp for price from text
([\d]+\.*[\d]+)
из строки "розничная цена: 154.22 грн" достанет "154.22"
или из строки "розничная цена: 15422 грн" достанет "15422"
@xto3na
xto3na / Слежение за курсором на jquery
Created February 11, 2017 23:11
Слежение за курсором на jquery
<div class="move-wrap">
<div id="follower"></div>
</div>
<style>
#follower{
position : relative;
background-color : #000;
width:10px;
height:10px; /* Размеры движущегося объекта */
@xto3na
xto3na / Ie и Edge убрать значки крестика и глаза с полей ввода
Created February 8, 2017 17:50
Ie и Edge убрать значки крестика и глаза с полей ввода
/* don't show the x for text inputs */
::-ms-clear {
width : 0;
height: 0;
}
/* don't show the eye for password inputs */
::-ms-reveal {
width : 0;
height: 0;