@@ -16,18 +16,18 @@ var id2name = require('./axis_ids').id2name;
16
16
module . exports = function handleConstraintDefaults ( containerIn , containerOut , coerce , counterAxes , layoutOut ) {
17
17
var constraintGroups = layoutOut . _axisConstraintGroups ;
18
18
19
- if ( ! containerIn . scalewith ) return ;
19
+ if ( ! containerIn . scaleanchor ) return ;
20
20
21
21
var constraintOpts = getConstraintOpts ( constraintGroups , containerOut . _id , counterAxes , layoutOut ) ;
22
22
23
- var scalewith = Lib . coerce ( containerIn , containerOut , {
24
- scalewith : {
23
+ var scaleanchor = Lib . coerce ( containerIn , containerOut , {
24
+ scaleanchor : {
25
25
valType : 'enumerated' ,
26
26
values : constraintOpts . linkableAxes
27
27
}
28
- } , 'scalewith ' ) ;
28
+ } , 'scaleanchor ' ) ;
29
29
30
- if ( scalewith ) {
30
+ if ( scaleanchor ) {
31
31
var scaleratio = coerce ( 'scaleratio' ) ;
32
32
// TODO: I suppose I could do attribute.min: Number.MIN_VALUE to avoid zero,
33
33
// but that seems hacky. Better way to say "must be a positive number"?
@@ -37,18 +37,18 @@ module.exports = function handleConstraintDefaults(containerIn, containerOut, co
37
37
if ( ! scaleratio ) scaleratio = containerOut . scaleratio = 1 ;
38
38
39
39
updateConstraintGroups ( constraintGroups , constraintOpts . thisGroup ,
40
- containerOut . _id , scalewith , scaleratio ) ;
40
+ containerOut . _id , scaleanchor , scaleratio ) ;
41
41
}
42
- else if ( counterAxes . indexOf ( containerIn . scalewith ) !== - 1 ) {
43
- Lib . warn ( 'ignored ' + containerOut . _name + '.scalewith : "' +
44
- containerIn . scalewith + '" to avoid an infinite loop ' +
42
+ else if ( counterAxes . indexOf ( containerIn . scaleanchor ) !== - 1 ) {
43
+ Lib . warn ( 'ignored ' + containerOut . _name + '.scaleanchor : "' +
44
+ containerIn . scaleanchor + '" to avoid an infinite loop ' +
45
45
'and possibly inconsistent scaleratios.' ) ;
46
46
}
47
47
} ;
48
48
49
49
function getConstraintOpts ( constraintGroups , thisID , counterAxes , layoutOut ) {
50
50
// If this axis is already part of a constraint group, we can't
51
- // scalewith any other axis in that group, or we'd make a loop.
51
+ // scaleanchor any other axis in that group, or we'd make a loop.
52
52
// Filter counterAxes to enforce this, also matching axis types.
53
53
54
54
var thisType = layoutOut [ id2name ( thisID ) ] . type ;
@@ -84,10 +84,10 @@ function getConstraintOpts(constraintGroups, thisID, counterAxes, layoutOut) {
84
84
*
85
85
* thisGroup: the group the current axis is already in
86
86
* thisID: the id if the current axis
87
- * scalewith : the id of the axis to scale it with
88
- * scaleratio: the ratio of this axis to the scalewith axis
87
+ * scaleanchor : the id of the axis to scale it with
88
+ * scaleratio: the ratio of this axis to the scaleanchor axis
89
89
*/
90
- function updateConstraintGroups ( constraintGroups , thisGroup , thisID , scalewith , scaleratio ) {
90
+ function updateConstraintGroups ( constraintGroups , thisGroup , thisID , scaleanchor , scaleratio ) {
91
91
var i , j , groupi , keyj , thisGroupIndex ;
92
92
93
93
if ( thisGroup === null ) {
@@ -103,11 +103,11 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scalewith,
103
103
var thisGroupKeys = Object . keys ( thisGroup ) ;
104
104
105
105
// we know that this axis isn't in any other groups, but we don't know
106
- // about the scalewith axis. If it is, we need to merge the groups.
106
+ // about the scaleanchor axis. If it is, we need to merge the groups.
107
107
for ( i = 0 ; i < constraintGroups . length ; i ++ ) {
108
108
groupi = constraintGroups [ i ] ;
109
- if ( i !== thisGroupIndex && groupi [ scalewith ] ) {
110
- var baseScale = groupi [ scalewith ] ;
109
+ if ( i !== thisGroupIndex && groupi [ scaleanchor ] ) {
110
+ var baseScale = groupi [ scaleanchor ] ;
111
111
for ( j = 0 ; j < thisGroupKeys . length ; j ++ ) {
112
112
keyj = thisGroupKeys [ j ] ;
113
113
groupi [ keyj ] = baseScale * scaleratio * thisGroup [ keyj ] ;
@@ -117,12 +117,12 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scalewith,
117
117
}
118
118
}
119
119
120
- // otherwise, we insert the new scalewith axis as the base scale (1)
120
+ // otherwise, we insert the new scaleanchor axis as the base scale (1)
121
121
// in its group, and scale the rest of the group to it
122
122
if ( scaleratio !== 1 ) {
123
123
for ( j = 0 ; j < thisGroupKeys . length ; j ++ ) {
124
124
thisGroup [ thisGroupKeys [ j ] ] *= scaleratio ;
125
125
}
126
126
}
127
- thisGroup [ scalewith ] = 1 ;
127
+ thisGroup [ scaleanchor ] = 1 ;
128
128
}
0 commit comments