Skip to content

Instantly share code, notes, and snippets.

View prisme's full-sized avatar

Jérémy Saint-Prix prisme

View GitHub Profile
/*
*
* Works with elements or jquery
*
* scrollTo(element, duration, offset);
*
* Update 'scroller' variable with custom scrolling element if not document.body
*
*/
@prisme
prisme / amd-easing.js
Last active February 11, 2024 22:10
easing AMD module
define([], function() {
//use: module.easeInExpo( time, beginning value, change in value, duration );
return {
linear: function (t, b, c, d) {
return (t==0) ? b : c*(t/=d) + b;
},
easeInQuad: function (t, b, c, d) {
return c*(t/=d)*t + b;
},
@prisme
prisme / fullframe.js
Created April 30, 2013 14:03
"full-frame" resize handling jQuery plugin : resizing/centering/cropping an asset in its parent, according to their respective ratio. parent needs an overflow:hidden
$.fn.centerIn = function (parent) {
var parentHeight = parent.height(),
parentWidth = parent.width(),
assetHeight = this.height(),
assetWidth = this.width(),
parentRatio = parentWidth / parentHeight,
assetRatio = assetWidth / assetHeight;
//----> ratio
if ( parentRatio < imgRatio ) {