Skip to content

Commit b53eb86

Browse files
committed
Remove the activeChanged method since it doesn't do anything different that the super kinds method
Add some documentation
1 parent c931c8f commit b53eb86

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

v2/AnimatedToggleButton/AnimatedToggleButton.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.onyx-toggle-button.onyx-animated-toggle-button {
2+
/* We need this so that the knob is positioned relatively to the toggle button */
23
position: relative;
34
}
45

v2/AnimatedToggleButton/AnimatedToggleButton.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
/**
2-
A control that looks like a switch with labels for two states. Each time a ToggleButton is tapped,
3-
it switches its value and fires an onChange event.
4-
5-
{kind: "onyx.ToggleButton", onContent: "foo", offContent: "bar", onChange: "buttonToggle"}
6-
7-
buttonToggle: function(inSender, inEvent) {
8-
this.log("Toggled to value " + inEvent.value);
9-
}
10-
11-
To find out the value of the button, use getValue:
12-
13-
queryToggleValue: function() {
14-
return this.$.toggleButton.getValue();
15-
}
2+
An extension fo the ToggleButton kind that animates between the on and off position and allows actual dragging of the knob.
163
*/
174
enyo.kind({
185
name: "onyx.AnimatedToggleButton",
@@ -34,10 +21,6 @@ enyo.kind({
3421
}
3522

3623
},
37-
activeChanged: function() {
38-
this.setValue(this.active);
39-
this.bubble("onActivate");
40-
},
4124
onContentChanged: function() {
4225
this.inherited(arguments);
4326
this.calculateSlidingBounds();
@@ -54,11 +37,14 @@ enyo.kind({
5437
},
5538
rendered: function() {
5639
this.inherited(arguments);
40+
// Do this after the Control has been rendered so that the sliding bounds can be calculated properly
5741
this.valueChanged();
5842
},
43+
// Calculate the maximum sliding position for the knob
5944
calculateSlidingBounds: function() {
6045
this.$.knob.setMax(this.getBounds().width-this.$.knob.getBounds().width-2);
6146
},
47+
// Prevent the drag handling of the super kind
6248
dragstart: function(inSender, inEvent) {
6349
},
6450
drag: function(inSender, inEvent) {

0 commit comments

Comments
 (0)