Skip to content

Instantly share code, notes, and snippets.

@IvanofSA
IvanofSA / scroll.js
Created August 5, 2020 11:36
add class
const scroll = fromEvent(window, 'scroll');
scroll.subscribe(showSection);
function showSection() {
const sectionObs = section => {
const interSection = new IntersectionObserver(entrie => {
entrie[0].intersectionRatio > 0.15 ?
!section.classList.contains('active') && section.classList.add('active')
: section.classList.remove('active');
});
@IvanofSA
IvanofSA / grids
Created June 22, 2020 09:32
mixins grid
@mixin grid() {
display: flex;
flex-wrap: wrap;
@supports (grid-area: auto) {
display: grid;
grid-gap: 16px 16px;
}
}
@IvanofSA
IvanofSA / index.js
Created May 22, 2020 11:14
parallax
const body = document.body;
const content = document.querySelector('.js-content');
const blocks = document.querySelectorAll('.block-scroll');
const updateOffset = () => {
requestAnimationFrame(updateOffset);
body.style.setProperty('--y', content.scrollTop);
updateProps();
};
@IvanofSA
IvanofSA / maps.vue
Created January 17, 2020 08:29
maps
<template>
<div ref="map" class="map">
<button @click="toggleFilters" class="map__button-filters" :class="isClassIsFiltersOpen">
<img v-if="isShowFilters" class="map__icon-filters" src="/images/order/img/filter_active.svg">
<img v-else class="map__icon-filters" src="/images/order/img/filter.svg">
{{isShowFilters ? 'Скрыть фильтры' : 'Показать фильтры'}}
</button>
<div id="yandexmap" class="map__yandexmap"></div>
</div>
</template>
@IvanofSA
IvanofSA / index.js
Created October 15, 2019 11:46
validate
import Validator from './modules/module.validate'
let validator = new Validator({
fields: {
current: {
empty: {
message: 'Поле обязательно к заполнению'
}
},
checkbox: {
unchecked: {
@IvanofSA
IvanofSA / MyReduce.js
Created October 15, 2019 11:41
MyReduce.js
const tree = {
name: '/',
children:
[
{
name: 'eTc', children: [
{
name: 'config.json',
meta: {},
@IvanofSA
IvanofSA / tree.js
Created September 23, 2019 11:57
reduce
const tree = {
name: '/',
children:
[
{
name: 'eTc', children: [
{
name: 'config.json',
meta: {},
type: 'file'
@IvanofSA
IvanofSA / deepEqual.js
Created September 18, 2019 09:22
Сравнение объектов
var objA = {
prop1: 'value1',
prop2: 'value2',
prop3: 'value3',
// prop7: ['value3', 'sd'],
prop4: {
subProp1: 'sub value1',
subProp2: {
subSubProp1: 'sub sub value1',
subSubProp2: [1, 2, {prop2: 1, prop: 2}, 4, 5]
@IvanofSA
IvanofSA / hover-underline.css
Last active January 9, 2019 10:33
hover underline
a {
color: blue;
text-decoration: none;
background-image: linear-gradient(currentColor, currentColor);
background-position: 0% 100%;
background-repeat: no-repeat;
background-size: 0% 2px;
transition: background-size .3s;
}
const re1 = new RegExp('hey'); // объекта RegExp
const re2 = /hey/; //литерал регулярных выражений
/*RegExp.test(String) -> boolean*/
/^hey/.test('hey'); // ^ - найти строки которые начинаются с hey
/hey$/.test('hey'); // $ - найти строки которые заканчиваются с hey
/^hey$/.test('hey'); // ^ что то тут $ - строка которая полностью совпадает