Skip to content

Instantly share code, notes, and snippets.

View umkasanki's full-sized avatar

Oleg Tishkin umkasanki

View GitHub Profile
@umkasanki
umkasanki / _resize.js
Created March 25, 2019 12:59
Done Resizing Event
let resizeTimer = 0;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
console.log($(window).width());
// Run code here, resizing has "stopped"
$('#js-contact-form').submit(function(ev) {
// Prevent the form from actually submitting
ev.preventDefault();
// Send it to the server
$.post({
url: '/',
dataType: 'json',
data: $(this).serialize(),
success: function(response) {
<section class="contact">
{% macro errorList(errors) %}
{% if errors %}
<ul class="errors">
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
@umkasanki
umkasanki / scss
Created February 6, 2019 06:29
SCSS grid mixin
@mixin row($gap: $gap, $justify-content: flex-start, $align-items: flex-start, $wrap: wrap) {
display: flex;
width: auto;
justify-content: $justify-content;
align-items: $align-items;
flex-wrap: $wrap;
@if $gap != 0 {
margin-left: $gap * -1;
}
/* eslint-env node */
// package vars
const pkg = require('./package.json');
const webpack = require('webpack-stream');
const gulp = require('gulp');
// load all plugins in "devDependencies" into the variable $
const $ = require('gulp-load-plugins')({
pattern: ['*'],
scope: ['devDependencies'],
@umkasanki
umkasanki / sticky.js
Created February 5, 2019 11:45
Sticky panel with Intersection Observer and position fixed. Add class if parent is offscreen
const sticky = function (panelsClass, elementsClass) {
const panels = document.querySelectorAll('.' + panelsClass);
const config = {
rootMargin: '150px 20px 75px 30px',
threshold: [0, 0.25, 0.75, 1]
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
@umkasanki
umkasanki / better-font-smoothing.css
Created February 5, 2019 06:31 — forked from hsleonis/better-font-smoothing.css
Better font smoothing in cross browser
html {
/* Adjust font size */
font-size: 100%;
-webkit-text-size-adjust: 100%;
/* Font varient */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
@umkasanki
umkasanki / css
Created December 10, 2018 07:18
Buttons. Material Design ripple effect
.container {
background-color: #c1c1c1;
height: 500px;
display: flex;
justify-content: center;
align-items: center;
}
.btn {
background-color: orange;
@umkasanki
umkasanki / twig
Created December 6, 2018 08:55
CraftCms. Get entries or products based on nested categories in url
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Category</title>
</head>
<body>
{% set catSegments = craft.request.segments|slice(1) %}
{% for item in catSegments %}
{% if craft.categories.slug(item).one() == null %}
@umkasanki
umkasanki / .twig
Last active November 20, 2022 15:32
Craftcms. nested categories in entry url
Expertise channel settings:
Entry URI Format: expertise/{category.inReverse().one().uri}/{slug}
Category group settings:
Category URI Format: {parent.uri}/{slug}