Skip to content

Instantly share code, notes, and snippets.

View bezenson's full-sized avatar
💻

Vladislav Bezenson bezenson

💻
  • Warsaw
View GitHub Profile
@bezenson
bezenson / _transition.scss
Created March 11, 2017 15:37
Shorten transition declaration via SASS (SCSS) function
// Default variables
$transition-duration: .2s;
$transition-timing-function: ease;
@function transition($arguments...) {
$result: null;
@each $prop in $arguments {
$result: $result, $prop $transition-duration $transition-timing-function;
}
@return $result;
;(function () {
// Scroll Variables (tweakable)
var defaultOptions = {
// Scrolling Core
frameRate : 150, // [Hz]
animationTime : 400, // [ms]
stepSize : 100, // [px]
@bezenson
bezenson / gulp.spritesmiths-resized.scss
Created July 10, 2016 11:15
Resize Gulp Smiths Sprite
@mixin sprite-resized($sprite-image, $ratio) {
background-position: (nth($sprite-image, 3) * $ratio) (nth($sprite-image, 4) * $ratio);
background-size: (nth($sprite-image, 7) * $ratio) (nth($sprite-image, 8) * $ratio);
width: nth($sprite-image, 5) * $ratio;
height: nth($sprite-image, 6) * $ratio;
}
// Notice: background-image not specified here. Extend from common sprite class or add manually.
.logo {
@include sprite-resized($icon-logo, 0.5);
$social-brands: (
behance: #1769ff,
dribbble: #ea4c89,
facebook: #3b5998,
github: #666,
google-plus: #dc4e41,
instagram: #3f729b,
linkedin: #0077b5,
odnoklassniki: #ed812b,
pinterest: #bd081c,
@bezenson
bezenson / index.html
Created April 27, 2014 13:01
jQuery Tabs
<!-- http://jsfiddle.net/evMdx/ -->
<div class="tabs">
<ul>
<li>Tab 1</li>
<li>Tab 2</li>
</ul>
<div class="tabsCont">
<div class="tab">first</div>
<div class="tab">Second</div>
@bezenson
bezenson / embed-inputs.jquery.js
Last active August 29, 2015 14:00
Instead of box-sizing: border-box for inputs, textarea and others
function embedInputs($selector) {
$selector.each(function() {
var $this = $(this);
$this.width(1);
if($this.is('textarea')) {
$this.css({'min-width': '', 'max-width': ''});
}
var additionalWidth =
@bezenson
bezenson / viewport-width.jquery.js
Created April 27, 2014 12:54
Get Viewport Width
function viewportWidth() {
var $body = $('body'),
viewPortWidth = $body.css('overflow', 'hidden').width();
$body.css('overflow', '');
return viewPortWidth;
}
@bezenson
bezenson / example.js
Last active August 29, 2015 14:00
jQuery Tooltip
$('.tt[title]').tooltip(200,200);
@bezenson
bezenson / smooth-mouse-scrolling.jquery.js
Created April 27, 2014 12:46
Smooth mouse scrolling
// This script don't work very good. It will be very good, if you can to improve it :)
var page = $('body'),
scrollRange = 60,
scrollSpeed = 200;
$(window).mousewheel(function(event, delta, deltaX, deltaY) {
if (delta < 0) {
page.stop(true,true).animate({scrollTop: page.scrollTop()+scrollRange}, scrollSpeed);
} else if (delta > 0) {
page.stop(true,true).animate({scrollTop: page.scrollTop()-scrollRange}, scrollSpeed);
@bezenson
bezenson / debounce.js
Last active October 9, 2017 12:21
Wait while event will end
var debounce = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = 'default';
}
if (timers[uniqueId]) {
clearTimeout(timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);