Skip to content

Instantly share code, notes, and snippets.

View SilencerWeb's full-sized avatar

Max Gorodov SilencerWeb

View GitHub Profile
@SilencerWeb
SilencerWeb / doesElemExist
Created June 28, 2017 07:34
function for check does element exist or not
function doesElemExist(elemName) {
return $(elemName).length > 0 ? true : false;
}
var gulp = require("gulp"),
browserSync = require("browser-sync"),
plugins = require("gulp-load-plugins")();
plugins.del = require("del");
var path = {
dest: {
pug: 'dist',
sass: 'dist/css',
js: 'dist/js',
{
"name": "gulpfile",
"version": "1.0.0",
"main": "index.js",
"author": "Maksim Gorodov <Silencer.Web@mail.ru>",
"license": "MIT",
"dependencies": {
"autoprefixer": "^7.1.1",
"browser-sync": "^2.18.12",
"css-mqpacker": "^6.0.1",
var _document = $(document);
_document.on("click", ".tabs__menu-link", function (e) {
e.preventDefault();
var _this = $(this),
tabs = _this.closest(".tabs"),
allTabsMenuItems = tabs.find(".tabs__menu-item"),
allTabsContentItems = tabs.find(".tabs__content-item");
allTabsMenuItems.removeClass("tabs__menu-item_active");
var _document = $(document),
_window = $(window),
body = $("body");
var modals = function () {
var overlay = $(".overlay"),
modalsWrapper = $(".modals-wrapper"),
modal = $(".modal"),
setTimeout;
var _document = $(document),
mainNavList = $('.header__nav-list'),
mainNavToggle = $('.header__nav-toggle'),
header = $('.header');
_document.on('click', '.header__nav-toggle', function (e) {
e.preventDefault();
mainNavList.toggleClass('header__nav-list_active');
mainNavToggle.toggleClass('header__nav-toggle_active');
return false;
[Here is a site][1], in it a canvas (airplane), which lags when scrolling, appear artifacts, and in different ways, depending on what you scroll - with the mouse wheel or scrollbar. If you comment out parallax or video at the beginning, nothing changes. During the scrolling of calls to the house does not happen. Lags either from behind the airplane script, or because of a clearRect. How can I optimize and get rid of artifacts? The code on the [codepen][2].
P.S. Artifacts do not appear on the [codepen][2], they are only on the [site][1]!
JS-code:
var scrolled;
var positionsArr = [];
var commonHeight = 0;
var canvas = document.querySelector('#canvas');
var img = new Image();
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
img.src = imageUrl;
img.onload = function () {
canvas.width = img.width;
canvas.height = 100;
ctx.drawImage(img, 0, 0);
img.style.display = 'none';
import React from 'react';
import Form from '../../components/Form';
import BooksList from '../../components/BooksList';
class App extends React.Component {
state = {
books: [
{
title: 'JavaScript and jQuery',
@SilencerWeb
SilencerWeb / Checkbox.jsx
Created December 10, 2017 12:20
Checkbox
import React from 'react';
import styled from 'styled-components';
function Checkbox(props) {
return (
<div className={ props.className } onClick={ () => props.toggle(props.name) }>
<input id={ props.name } type="checkbox" checked={ props.checked }/>
{ props.text }
<span onClick={ props.uncheckAll }>Только</span>
</div>