diff --git a/README.md b/README.md index 9520f83..65d3e28 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Vue.component('ToggleButton', ToggleButton) | switchColor | [String, Object] | `#BFCBD9` | If `String` - color or background property of the switch when checked
If `Object` - colors or background property for the switch when checked/uncheked
Example: `{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}` | | width | Number | 50 | Width of the button | | height | Number | 22 | Height of the button | +| margin | Number | 3 | Space between the switch and background border | | name | String | undefined | Name to attach to the generated input field | | fontSize | Number | undefined | Font size | diff --git a/demo/src/App.vue b/demo/src/App.vue index 6e4ff6b..414f58d 100644 --- a/demo/src/App.vue +++ b/demo/src/App.vue @@ -43,7 +43,7 @@ :disabled="true"/> @@ -63,6 +63,11 @@ +
typeof object === 'object' && object.hasOwnProperty(title) @@ -101,6 +100,10 @@ export default { type: Number, default: 50 }, + margin: { + type: Number, + default: 3 + }, fontSize: { type: Number } @@ -124,19 +127,19 @@ export default { }, buttonRadius () { - return this.height - MARGIN * 2; + return this.height - this.margin * 2; }, distance () { - return px(this.width - this.height + MARGIN) + return px(this.width - this.height + this.margin) }, buttonStyle () { const transition = `transform ${this.speed}ms` const transform = this.toggled - ? `translate3d(${this.distance}, 3px, 0px)` - : null + ? `translate3d(${this.distance}, ${px(this.margin)}, 0px)` + : `translate3d(${px(this.margin)}, ${px(this.margin)}, 0px)` const background = this.switchColor ? this.switchColorCurrent @@ -263,12 +266,10 @@ export default {