var test = {
foo: 123
}
watch(test, 'foo', function(val) {
console.log('Prop changed to ', val);
});
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
/* | |
Converts percents (or any value in %, px, int) to pixels. | |
pixelize("50%", 1000); // 500 | |
*/ | |
function pixelize(value, quantity) { | |
if ("string" == typeof value) { | |
if (value.substr(-1)==='%') { | |
return ((quantity/100)* (value.substring(0, value.length-1))); | |
} else { | |
return parseInt(value.split('px').join('')); |
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
*.-morulus-customsb { | |
position:relative; | |
width:100%;height:100%; | |
overflow:hidden; | |
} | |
*.-morulus-customsb > figure:first-child { | |
margin: 0px !important; | |
position: absolute; | |
right: 4px !important; |
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() { | |
var vendors = ['ms', 'moz', 'webkit', 'o'],customRequestAnimationFrame=window.requestAnimationFrame,customCancelAnimationFrame=window.cancelAnimationFrame; | |
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { | |
customRequestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; | |
customCancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] | |
|| window[vendors[x]+'CancelRequestAnimationFrame']; | |
}; | |
window.requestAnimationFrame = function() { | |
customRequestAnimationFrame.apply(window, arguments); | |
}; |
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
/* | |
Special solution to hide vertical body scroll in FF, without disabling scroll. | |
Usage: | |
<body></body> | |
<script> | |
firefoxHideScrollbar(); | |
</script> | |
*/ | |
;(function(purpose) { | |
// Event listner polyfill |
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
var mixin = (function() { | |
var mixinup = function(a,b) { | |
for(var i in b) { | |
if (b.hasOwnProperty(i)) { | |
a[i]=b[i]; | |
} | |
} | |
return a; |
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
// Remove event listner polyfill | |
varremoveEventListner = function(el, type, handler) { | |
if ( el.addEventListener ) { | |
el.removeEventListener(type, handler, false); | |
} else if ( elem.attachEvent ) { | |
el.detachEvent("on" + type, handler); | |
} else { | |
el["on"+type] = 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
/* | |
Функция принимает массив чисел и возвращает отношение каждого к их сумме | |
Returns array of ratios | |
*/ | |
var ratioThSum = function(numbers) { | |
var sum=0,i,r=[]; | |
for (i=0;i<numbers.length;++i) sum+=numbers[i]; | |
for (i=0;i<numbers.length;++i) r.push(numbers[i]/sum); | |
return r; | |
} |
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 sure(ob, key, constr) { | |
if (!(ob[key] instanceof constr)) ob[key] = new constr(); | |
return ob[key]; | |
} |
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
/* | |
Source must be an object where | |
{ | |
width: integer // Width of source rect | |
height: integer // Height of source rect | |
} | |
Rect is same object where | |
{ | |
width: integer |
OlderNewer