This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function goTo(index) { | |
var dir = 1; // -1 | |
var currentIndex = (dir * index + slidesLength) % slidesLength | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ValidationTest(options) { | |
this.value = options.value; | |
this.rules = options.rules || []; | |
this.onSuccess = options.onSuccess; | |
this.onError = options.onError; | |
}; | |
ValidationTest.prototype.destroy = function() { | |
this.value = null; | |
this.rules = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$media = { | |
medium: "(min-width: 992px)", | |
small: "(min-width: 768px)" | |
} | |
mq($mq) | |
if $mq in $media | |
$condition = $media[$mq] | |
else | |
$condition = $mq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let browserSync = require('browser-sync').create(); | |
browserSync.init({ | |
proxy: 'http://site.com', | |
serveStatic: ['static'], | |
files: ['static/**/*.*'], | |
rewriteRules: [ | |
{ | |
match: /<\/head>/i, | |
fn: (req, res, match) => `<link rel="stylesheet" href="/custom.css" />` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Битовые маски в UI | |
* Автор: Игорь Алексеенко | |
*/ | |
// состояния компонентов | |
class Button { | |
constructor() { | |
this.state = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://codepen.io/32bitkid/post/understanding-delegated-javascript-events | |
var delegate = function(criteria, listener) { | |
return function(e) { | |
var el = e.target; | |
do { | |
if (!criteria(el)) continue; | |
e.delegateTarget = el; | |
listener.apply(this, arguments); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>History Test</title> | |
<style> | |
html { | |
font: 100%/1.5 sans-serif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const applyMiddleware = (...middlewares) => store => { | |
if (middlewares.length === 0) { | |
return dispatch => dispatch; | |
} | |
if (middlewares.length === 1) { | |
return middlewares[0]; | |
} | |
const boundMiddlewares = middlewares.map(middleware => | |
middleware(store); | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://dassur.ma/things/lazyloading/ --> | |
<head> | |
<!-- ... --> | |
<noscript class="lazyload"> | |
<link | |
rel="stylesheet" | |
href="/styles/things.css"> | |
</noscript> | |
<!-- ... --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://dassur.ma/things/raf-promise/ | |
function transitionEndPromise(element, styles) { | |
return new Promise(resolve => { | |
element.addEventListener('transitionend', function f(event) { | |
if (event.target !== element) return; | |
element.removeEventListener('transitionend', f); | |
resolve(); | |
}); | |
Object.assign(element.style, styles); |