11<template >
22<label :class =" className" >
3- <input type =" checkbox"
4- class =" v-switch-input"
5- :name =" name"
6- :checked =" value"
7- :disabled =" disabled"
8- @change.stop =" toggle" >
9- <div class =" v-switch-core"
10- :style =" coreStyle" >
11- <div class =" v-switch-button"
12- :style =" buttonStyle" />
3+ <input
4+ type =" checkbox"
5+ class =" v-switch-input"
6+ :name =" name"
7+ :checked =" value"
8+ :disabled =" disabled"
9+ @change.stop =" toggle"
10+ >
11+ <div
12+ class =" v-switch-core"
13+ :style =" coreStyle"
14+ >
15+ <div
16+ class =" v-switch-button"
17+ :style =" buttonStyle"
18+ />
1319 </div >
1420 <template v-if =" labels " >
15- <span class =" v-switch-label v-left"
16- :style =" labelStyle"
17- v-if =" toggled" >
21+ <span
22+ class =" v-switch-label v-left"
23+ :style =" labelStyle"
24+ v-if =" toggled"
25+ >
1826 <slot name =" checked" >
1927 <template >{{labelChecked}}</template >
2028 </slot >
2129 </span >
22- <span class =" v-switch-label v-right"
23- :style =" labelStyle"
24- v-else >
30+ <span
31+ class =" v-switch-label v-right"
32+ :style =" labelStyle"
33+ v-else
34+ >
2535 <slot name =" unchecked" >
2636 <template >{{labelUnchecked}}</template >
2737 </slot >
@@ -42,6 +52,10 @@ const contains = (object, title) =>
4252
4353const px = v => v + ' px'
4454
55+ const translate3d = (x , y , z = ' 0px' ) => {
56+ return ` translate3d(${ x} , ${ y} , ${ z} )`
57+ }
58+
4559export default {
4660 name: ' ToggleButton' ,
4761 props: {
@@ -112,7 +126,7 @@ export default {
112126 computed: {
113127 className () {
114128 let { toggled, disabled } = this
115-
129+
116130 return [' vue-js-switch' , { toggled, disabled }]
117131 },
118132
@@ -137,10 +151,11 @@ export default {
137151
138152 buttonStyle () {
139153 const transition = ` transform ${ this .speed } ms`
154+ const margin = px (this .margin )
140155
141156 const transform = this .toggled
142- ? ` translate3d(${ this .distance } , ${ px ( this . margin )} , 0px) `
143- : ` translate3d(${ px ( this . margin ) } , ${ px ( this . margin )} , 0px) `
157+ ? translate3d (this .distance , margin)
158+ : translate3d (margin, margin)
144159
145160 const background = this .switchColor
146161 ? this .switchColorCurrent
0 commit comments