Skip to content

Instantly share code, notes, and snippets.

@Alex2033
Alex2033 / Scroll Down Button
Last active July 12, 2018 05:25
The example of button to scroll down to next section
Pug:
button.down-anchor
i.fa.fa-angle-double-down
JQuery:
$(function() {
$('.down-anchor').on('click', function(e) {
e.preventDefault();
$('html, body').animate({ scrollTop: $(window).height()}, 500, 'linear');
});
$(window).scroll(function startCounter() {
if ($(window).scrollTop() > $(".count").offset().top) {
$(window).off("scroll", startCounter)
$('.count').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.attr("data-number") }, {
duration: 2000,
easing: 'swing',
step: function () {
$this.text(Math.ceil(this.Counter));
@Alex2033
Alex2033 / Fixing the main-nav block script
Created May 18, 2018 13:53
Fixing the main-nav block script
$(document).ready(function() {
toplogo_pos = $('.header').offset().top; // определяем его первоначальное положение
$(window).scroll(function(){
if ($(window).scrollTop() > toplogo_pos){ // Если страницу прокрутили дальше, чем находится наш блок
$('.header').css({'background-color': 'rgba(0,0,0,0.6'}); // То мы этот блок фиксируем и отображаем сверху.
}else{ // Если же позиция скрола меньше (выше), чем наш блок
$('.header').css({'background-color': 'transparent'}); // то возвращаем все назад
}
@Alex2033
Alex2033 / Blocks with the same height
Last active February 26, 2018 18:15
Blocks with the same height
$(document).ready(function() {
setTimeout(function() {
var mainDivs = $(".YOUR-BLOCK"); //Получаем все элементы с классом YOUR-BLOCK
var maxHeight = 0;
for (var i = 0; i < mainDivs.length; ++i) {
if (maxHeight < $(mainDivs[i]).height()) { //Находим максимальную высоту
maxHeight = $(mainDivs[i]).height();
}
}
for (var i = 0; i < mainDivs.length; ++i) {
@Alex2033
Alex2033 / ScrollUp
Last active July 11, 2018 03:35
ScrollUp
Sass:
#scrollUp
bottom: 20px
right: 20px
width: 50px
height: 50px
position: fixed
z-index: 50
border-radius: 4px
background-color: $accent
<snippet>
<content><![CDATA[
<!-- begin $1 -->
<div class="$1">
$2
</div>
<!-- end $1 -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>di</tabTrigger>
@Alex2033
Alex2033 / responsive menu[1]
Last active October 23, 2017 10:38
Pug + Sass + JQuery
PUG:
button.toggle-menu
span.sandwich
span.sw-topper
span.sw-bottom
span.sw-footer
nav.main-navigation
a(href="#") Обо мне
a(href="#") Резюме
@Alex2033
Alex2033 / button.sass
Created October 5, 2017 17:14 — forked from agragregra/button.sass
Button Sass Styles (Universal Starter)
.button
display: inline-block
border: none
color: #fff
text-decoration: none
background-color: $accent
padding: 15px 45px
font-size: 13px
text-transform: uppercase
font-weight: 600
$(document).ready(function(){
$(document).on('click', 'a', function(event){
event.preventDefault();
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
});
});
HTML:
<div class="wrapper">
<div class="tabs">
<span class="tab">Вкладка 1</span>
<span class="tab">Вкладка 2</span>
<span class="tab">Вкладка 3</span>
</div>
<div class="tab_content">
<div class="tab_item">Содержимое 1</div>
<div class="tab_item">Содержимое 2</div>