forked from vanderlee/coverflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.interpolate.js
48 lines (44 loc) · 1.34 KB
/
jquery.interpolate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*jslint devel: true, bitwise: true, regexp: true, browser: true, confusion: true, unparam: true, eqeq: true, white: true, nomen: true, plusplus: true, maxerr: 50, indent: 4 */
/*globals jQuery */
/*!
* Interpolate
*
* Copyright (c) 2013 Martijn W. van der Lee
* Licensed under the MIT.
*/
/* CSS style interpolation.
* Requires jQuery 1.8+.
* Optionally jQueryUI for color support
*/
;(function($, undefined) {
"use strict";
/**
* .interpolate( propertyName, propertyValue [, blend] [, easing] )
* .interpolate( propertyMap [, blend] [, easing] )
*/
$.fn.interpolate = function(name, value, blend, easing) {
var _elem = this[0];
if ($.isPlainObject(name)) {
easing = blend || 'linear';
blend = value === undefined ? .5 : value;
$.each(name, function(n, v) {
$.Tween(_elem, {duration: 1}, n, v, easing).run(blend);
});
} else {
blend = blend === undefined ? .5 : blend;
$.Tween(_elem, {duration: 1}, name, value, easing || 'linear').run(blend);
}
}
/**
* jQuery.interpolate( propertyMapStart, propertyMapEnd [, blend] [, easing] )
*/
$.interpolate = function(start, end, blend, easing) {
var elem = $('<span/>'),
state = $.extend({}, start);
elem.css(state).interpolate(end, blend, easing);
$.each(end, function(name, value) {
state[name] = elem.css(name);
});
return state;
}
}(jQuery));