Skip to content

Instantly share code, notes, and snippets.

View sergeche's full-sized avatar
🎯

Sergey Chikuyonok sergeche

🎯
View GitHub Profile
@sergeche
sergeche / example.js
Last active April 2, 2020 10:38
Простой анимационный контроллер. Суть простая: на каждый шаг анимации вызывает функцию `step`, которую передали вместе с опциями. Аргументом функции является значение от 0 до 1.
var elem = document.getElementById('elem');
var tween = new Tween({
easing: 'easeInOutCubic',
step: function(pos) {
// перемещаемся от 100px до 300px
elem.style.left = (100 + 200 * step) + 'px';
},
complete: function() {
console.log('animation complete');
}
@sergeche
sergeche / bembem.js
Created August 10, 2012 12:48
Trim b- prefix
// простая обётка, которая выполняет код в окружении ядра Zen Coding
// проедоставляет функции require (импорт модулей) и _ (библиотека underscore.js)
zen_coding.exec(function(require, _) {
var rePrefix = /\bb\-/g;
/**
* Рекурсивная функция, которая удаляет префикс b- у элемента и его потомков
* @param {AbbreviationNode} node
*/
function trimPrefix(node) {
@sergeche
sergeche / steps.js
Created March 19, 2012 11:21
Пример контроллера шагов
var StepModel = Backbone.Model.extend({
// шаблон для шага по умолчанию
template: 'steps/defaultTemplate',
initialize: function(data) {
// инициализруешь модель
// ...
// инициализация вьюхи
this.view = templates.render(data.template || this.template);
@sergeche
sergeche / gist:1817200
Created February 13, 2012 14:13
Треугольная кнопка
.button {
position: relative;
display: inline-block;
padding: 0 1em;
line-height: 2;
border-bottom: 1px solid #e6ad00;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
@sergeche
sergeche / zen_editor.py
Created November 15, 2011 21:10
SCSS support for Zen Coding TextMate
# right-click on Zen Coding.tmbundle, Show Package Contents, open Support/zen_editor.py and change line 170 to this:
doc_type = re.findall(r'\bhtml|css|xml|haml|scss\b', scope)[-1]
if doc_type == 'scss':
doc_type = 'css'
// Forcing Opera full page reflow/repaint to fix page draw bugs
function forceOperaRepaint() {
if (window.opera) {
var bs = document.body.style;
bs.position = 'relative';
setTimeout(function() {
bs.position = 'static';
}, 1);
}
}