fix firefox toggle, closes #69

requires another element :(
This commit is contained in:
Adam Bradley
2013-11-07 12:53:39 -06:00
parent afba3f1deb
commit 284b329555
6 changed files with 81 additions and 71 deletions

59
dist/css/ionic.css vendored
View File

@ -3911,31 +3911,27 @@ input[type="checkbox"][readonly] {
position: relative;
display: inline-block; }
.toggle input[type="checkbox"] {
/* set the actual checkbox input to have a width/height */
/* but hide its appearance, then use :after to style it */
/* hide the actual input checkbox */
.toggle input {
display: none; }
/* the track appearance when the toggle is "off" */
.toggle .track {
display: inline-block;
box-sizing: border-box;
width: 54px;
height: 32px;
border: 0;
background: transparent;
-webkit-appearance: none;
/* the track appearance when the toggle is "off" */ }
.toggle input[type="checkbox"]:after {
display: inline-block;
box-sizing: border-box;
width: 100%;
height: 100%;
border: solid 2px #e5e5e5;
border-radius: 20px;
background-color: #e5e5e5;
content: ' ';
cursor: pointer;
transition-timing-function: ease-in-out;
transition-duration: 0.1s;
transition-property: background-color, border; }
border: solid 2px #e5e5e5;
border-radius: 20px;
background-color: #e5e5e5;
content: ' ';
cursor: pointer;
transition-timing-function: ease-in-out;
transition-duration: 0.1s;
transition-property: background-color, border; }
/* the handle (circle) thats inside the toggle's track area */
/* also the appearance when the handle is "off" */
/* also the handle's appearance when it is "off" */
.toggle .handle {
position: absolute;
top: 2px;
@ -3945,25 +3941,26 @@ input[type="checkbox"][readonly] {
height: 28px;
border-radius: 50%;
background-color: white;
transition: -webkit-transform 0.1s ease-in-out;
-webkit-transition: 0.1s ease-in-out;
transition: 0.1s ease-in-out;
/* used to create a larger (but hidden) hit area to slide the handle */ }
.toggle .handle:before {
position: absolute;
top: -2px;
left: -16px;
display: table;
padding: 17px 30px;
top: -4px;
left: -22px;
padding: 19px 35px;
content: " "; }
/* The track when the toggle is "on" */
.toggle input:checked:after {
/* the track when the toggle is "on" */
.toggle input:checked + .track {
border-color: #4a87ee;
background-color: #4a87ee; }
/* the handle when the toggle is "on" */
.toggle input:checked + .handle {
background-color: white;
-webkit-transform: translate3d(22px, 0, 0); }
.toggle input:checked + .track .handle {
-webkit-transform: translate(22px, 0);
transform: translate(22px, 0);
background-color: white; }
/* make sure list item content have enough padding on right to fit the toggle */
.item-toggle .item-content {

View File

@ -1351,7 +1351,7 @@ angular.module('ionic.ui.toggle', [])
replace: true,
require: '?ngModel',
scope: true,
template: '<div class="toggle"><input type="checkbox"><div class="handle"></div></div>',
template: '<div class="toggle"><input type="checkbox"><div class="track"><div class="handle"></div></div></div>',
link: function($scope, $element, $attr, ngModel) {
var checkbox, handle;

View File

@ -8,7 +8,7 @@ angular.module('ionic.ui.toggle', [])
replace: true,
require: '?ngModel',
scope: true,
template: '<div class="toggle"><input type="checkbox"><div class="handle"></div></div>',
template: '<div class="toggle"><input type="checkbox"><div class="track"><div class="handle"></div></div></div>',
link: function($scope, $element, $attr, ngModel) {
var checkbox, handle;

View File

@ -197,6 +197,13 @@
// CSS3 PROPERTIES
// --------------------------------------------------
// Appearance
@mixin appearance($val) {
-webkit-appearance: $val;
-moz-appearance: $val;
appearance: $val;
}
// Border Radius
@mixin border-radius($radius) {
-webkit-border-radius: $radius;

View File

@ -8,35 +8,30 @@
display: inline-block;
}
.toggle input[type="checkbox"] {
/* set the actual checkbox input to have a width/height */
/* but hide its appearance, then use :after to style it */
/* hide the actual input checkbox */
.toggle input {
display: none;
}
/* the track appearance when the toggle is "off" */
.toggle .track {
display: inline-block;
box-sizing: border-box;
width: $toggle-width;
height: $toggle-height;
border: 0;
background: transparent;
-webkit-appearance: none;
border: solid $toggle-border-width $toggle-off-border-color;
border-radius: $toggle-border-radius;
background-color: $toggle-off-bg-color;
content: ' ';
cursor: pointer;
/* the track appearance when the toggle is "off" */
&:after {
display: inline-block;
box-sizing: border-box;
width: 100%;
height: 100%;
border: solid $toggle-border-width $toggle-off-border-color;
border-radius: $toggle-border-radius;
background-color: $toggle-off-bg-color;
content: ' ';
cursor: pointer;
transition-timing-function: ease-in-out;
transition-duration: $toggle-transition-duration;
transition-property: background-color, border;
}
transition-timing-function: ease-in-out;
transition-duration: $toggle-transition-duration;
transition-property: background-color, border;
}
/* the handle (circle) thats inside the toggle's track area */
/* also the appearance when the handle is "off" */
/* also the handle's appearance when it is "off" */
.toggle .handle {
position: absolute;
top: $toggle-border-width;
@ -46,29 +41,28 @@
height: $toggle-handle-height;
border-radius: $toggle-handle-radius;
background-color: $toggle-handle-off-bg-color;
transition: -webkit-transform $toggle-transition-duration ease-in-out;
@include transition($toggle-transition-duration ease-in-out);
/* used to create a larger (but hidden) hit area to slide the handle */
&:before {
position: absolute;
top: -2px;
left: ( ($toggle-handle-width / 2) * -1) - 2;
display: table;
padding: ($toggle-handle-height / 2) + 3 ($toggle-handle-width + 2);
top: -4px;
left: ( ($toggle-handle-width / 2) * -1) - 8;
padding: ($toggle-handle-height / 2) + 5 ($toggle-handle-width + 7);
content: " ";
}
}
/* The track when the toggle is "on" */
.toggle input:checked:after {
/* the track when the toggle is "on" */
.toggle input:checked + .track {
border-color: $toggle-on-border-color;
background-color: $toggle-on-bg-color;
}
/* the handle when the toggle is "on" */
.toggle input:checked + .handle {
.toggle input:checked + .track .handle {
@include translate($toggle-width - $toggle-handle-width - ($toggle-border-width * 2), 0);
background-color: $toggle-handle-on-bg-color;
-webkit-transform: translate3d( $toggle-width - $toggle-handle-width - ($toggle-border-width * 2) ,0,0);
}
/* make sure list item content have enough padding on right to fit the toggle */

View File

@ -22,7 +22,9 @@
</div>
<label class="toggle">
<input type="checkbox" checked>
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
<li class="item item-toggle">
@ -31,7 +33,9 @@
</div>
<label class="toggle">
<input type="checkbox" checked>
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
<li class="item item-toggle">
@ -40,7 +44,9 @@
</div>
<label class="toggle">
<input type="checkbox">
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
<li class="item item-toggle">
@ -49,7 +55,9 @@
</div>
<label class="toggle">
<input type="checkbox">
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
<li class="item item-toggle">
@ -58,7 +66,9 @@
</div>
<label class="toggle">
<input type="checkbox" checked>
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
<li class="item item-toggle">
@ -67,7 +77,9 @@
</div>
<label class="toggle">
<input type="checkbox">
<div class="handle"></div>
<div class="track">
<div class="handle"></div>
</track>
</label>
</li>
</ul>