Skip to content

Instantly share code, notes, and snippets.

View hatamsoyunov's full-sized avatar

Hatam hatamsoyunov

View GitHub Profile
@hatamsoyunov
hatamsoyunov / index.pug
Created September 9, 2020 18:54
Baron.js - UI Scroll, custom scroll
.ui-scroll
._bar
._drag
._container
Lorem ipsum
@hatamsoyunov
hatamsoyunov / declOfNum.ts
Last active December 10, 2020 10:17 — forked from realmyst/gist:1262561
Склонение числительных в javascript
export const declOfNum = (number: number, titles: string[]) => {
const cases = [2, 0, 1, 1, 1, 2];
return titles[number % 100 > 4 && number % 100 < 20 ? 2 : cases[number % 10 < 5 ? number % 10 : 5]];
};
{
"printWidth": 140,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
@hatamsoyunov
hatamsoyunov / index.js
Last active January 26, 2020 13:15
FAQ collapse
// FAQ Collapse
$('.js-collapse').click(function(e) {
var faqItem = $(this);
var allFaqItem = faqItem.closest('.faq-collapses').find('.faq-collapse');
var faqCollapse = faqItem.children('.faq-collapse__text');
var allHelpCollapse = faqItem
.closest('.faq-collapses')
.find('.faq-collapse__text');
if (
@hatamsoyunov
hatamsoyunov / index.js
Last active January 31, 2020 00:47
Tabs
// tabs toggle
$('.tabs__link').click(function(e) {
e.preventDefault();
let tabs = $(this).closest('.tabs');
let btns = tabs.find('.tabs__link');
let contents = tabs.find('.tab__content');
let tabID = $(this).attr('href');
// Toggle btn
@hatamsoyunov
hatamsoyunov / main.js
Created December 7, 2019 23:11
Owl counter
// Renders
const nextArrow = '<svg class="icon icon--next"><use xlink:href="img/svg-sprite.svg#next"></use></svg>';
$('#renders').owlCarousel({
loop: false,
margin: 0,
nav: true,
items: 1,
smartSpeed: 900,
navSpeed: 900,
@hatamsoyunov
hatamsoyunov / pagination.pug
Last active October 16, 2019 11:16
Pagination generate mixin
mixin pagination(pages)
- var i = 2;
.b-pagination
ul._list
li._item
a(href="#")._link Prev
li._item.-active
span._link 1
while i < pages + 1
@hatamsoyunov
hatamsoyunov / main.js
Created October 6, 2019 22:01
Page end scroll
$(window).scroll(function() {
let nextID = $('.case-intro').attr('next-case-id');
let windowScrollTop = $(window).scrollTop();
let windowHeight = $(window).height();
let docHeight = $(document).height();
if (windowScrollTop >= docHeight - windowHeight) {
nextCase(nextID);
}
});
@hatamsoyunov
hatamsoyunov / tween.js
Created September 30, 2019 05:50
tween from to
function tween(selector, from, to) {
$({p: from}).animate({p: to}, {
duration: 800,
easing: 'linear',
step: function (a) {
selector.html(Math.ceil(a) + '%');
}
});
}
function detectBrowser(){
let N = navigator.appName, ua= navigator.userAgent, tem;
let M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M = M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
return M;
}