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
/* Returns CSS rotateZ compatible angle for verctor */ | |
var getVectorAngle = function(x0,x,y0,y) { | |
if (y0===y) { | |
if (x>x0) angle = 0; | |
else if (x<x0) angle = 180; | |
else if (x===x0) angle = 0; | |
} else if (x0===x) { | |
if (y>y0) angle = 90; | |
else if (y0>y) angle = -90; | |
else angle = 0; |
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
function svgPathToCubicBezierPoints(path, percentRequired) { | |
var path=path.replace(/([\n])/g, ' ').replace(/[\t]+/g, ''),si=0,cubic=[], | |
task=0, | |
M_EREG = /M[\s\d\.\-\,]+[^\sSCLM]+/i, | |
c_EREG = /c[\s\d\.]+,[\d\.]+\-[\d\.]+,[\d\.]+[^\sSCLM]+/i, | |
s_EREG = /s[\s\d\.\-\,][^\sSCLM]+/i, | |
Parts = [],p=null,shift=0,cubic=[],vals,tonullx=0,tonully=0,i=0,locksblocks=[],addsx=0,addsy=0, | |
minx=9999999,miny=9999999,maxx=0,maxy=0; | |
// Search for M |
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; | |
} |
OlderNewer