diff options
Diffstat (limited to 'node_modules/montage-user/ui/flow-path-lerp.js')
-rw-r--r-- | node_modules/montage-user/ui/flow-path-lerp.js | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/node_modules/montage-user/ui/flow-path-lerp.js b/node_modules/montage-user/ui/flow-path-lerp.js new file mode 100644 index 00000000..b88fee39 --- /dev/null +++ b/node_modules/montage-user/ui/flow-path-lerp.js | |||
@@ -0,0 +1,106 @@ | |||
1 | var Montage = require("montage").Montage; | ||
2 | |||
3 | var FlowPathLerp = exports.FlowPathLerp = Montage.create(Montage, { | ||
4 | |||
5 | _path1: { | ||
6 | enumerable: false, | ||
7 | value: null | ||
8 | }, | ||
9 | |||
10 | _path2: { | ||
11 | enumerable: false, | ||
12 | value: null | ||
13 | }, | ||
14 | |||
15 | _interpolant: { | ||
16 | enumerable: false, | ||
17 | value: 0 | ||
18 | }, | ||
19 | |||
20 | path1: { | ||
21 | get: function () { | ||
22 | return this._path1; | ||
23 | }, | ||
24 | set: function (value) { | ||
25 | this._path1 = value; | ||
26 | this.resultPath = true; | ||
27 | } | ||
28 | }, | ||
29 | |||
30 | path2: { | ||
31 | get: function () { | ||
32 | return this._path2; | ||
33 | }, | ||
34 | set: function (value) { | ||
35 | this._path2 = value; | ||
36 | this.resultPath = true; | ||
37 | } | ||
38 | }, | ||
39 | |||
40 | interpolant: { | ||
41 | get: function () { | ||
42 | return this._interpolant; | ||
43 | }, | ||
44 | set: function (value) { | ||
45 | this._interpolant = value; | ||
46 | this.resultPath = true; | ||
47 | } | ||
48 | }, | ||
49 | |||
50 | _resultPath: { | ||
51 | enumerable: false, | ||
52 | value: null | ||
53 | }, | ||
54 | |||
55 | resultPath: { | ||
56 | get: function () { | ||
57 | return this._resultPath; | ||
58 | }, | ||
59 | set: function () { | ||
60 | var self = this; | ||
61 | |||
62 | this._resultPath = { | ||
63 | value: function (slide) { | ||
64 | var v1=self._path1.value(slide), | ||
65 | v2=self._path2.value(slide), | ||
66 | m1=1-self._interpolant, | ||
67 | m2=self._interpolant, | ||
68 | result={}, | ||
69 | i; | ||
70 | |||
71 | for (i in v1) { | ||
72 | if (v1.hasOwnProperty(i)&&(i!="style")) { | ||
73 | if (v2.hasOwnProperty(i)) { | ||
74 | if ((typeof v1[i]==="number")&&(typeof v2[i]==="number")) { | ||
75 | result[i]=v1[i]*m1+v2[i]*m2; | ||
76 | } else { | ||
77 | result[i]=v1[i]; | ||
78 | } | ||
79 | } else { | ||
80 | result[i]=v1[i]; | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | for (i in v2) { | ||
85 | if (v2.hasOwnProperty(i)&&(i!="style")&&(!v1.hasOwnProperty(i))) { | ||
86 | result[i]=v2[i]; | ||
87 | } | ||
88 | } | ||
89 | if (v1.style) { | ||
90 | result.style={}; | ||
91 | for (i in v1.style) { | ||
92 | if (v1.style.hasOwnProperty(i)) { | ||
93 | if ((v2.style)&&(v2.style.hasOwnProperty(i))&&(typeof v1.style[i]==="number")&&(typeof v2.style[i]==="number")) { | ||
94 | result.style[i]=v1.style[i]*m1+v2.style[i]*m2; | ||
95 | } else { | ||
96 | result.style[i]=v1.style[i]; | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | return result; | ||
102 | } | ||
103 | }; | ||
104 | } | ||
105 | } | ||
106 | }); | ||