Skip to content

Commit

Permalink
perf(toggle): css containment
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Apr 7, 2017
1 parent bda624f commit 93d1d02
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/components/toggle/toggle.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ $toggle-ios-item-right-padding: 6px ($item-ios-padding-right / 2) 5px ($i

.toggle-ios {
position: relative;

width: $toggle-ios-width;
height: $toggle-ios-height;

box-sizing: content-box;

contain: strict;
}


Expand All @@ -70,8 +77,8 @@ $toggle-ios-item-right-padding: 6px ($item-ios-padding-right / 2) 5px ($i
position: relative;
display: block;

width: $toggle-ios-width;
height: $toggle-ios-height;
width: 100%;
height: 100%;

border-radius: $toggle-ios-border-radius;

Expand Down Expand Up @@ -117,6 +124,9 @@ $toggle-ios-item-right-padding: 6px ($item-ios-padding-right / 2) 5px ($i
box-shadow: $toggle-ios-handle-box-shadow;

transition: transform $toggle-ios-transition-duration, width 120ms ease-in-out 80ms, left 110ms ease-in-out 80ms;

will-change: transform;
contain: strict;
}


Expand Down
4 changes: 3 additions & 1 deletion src/components/toggle/toggle.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ $toggle-md-item-right-padding: 12px ($item-md-padding-right / 2) 12px
height: $toggle-md-track-height;

box-sizing: content-box;

contain: strict;
}


Expand Down Expand Up @@ -117,7 +119,7 @@ $toggle-md-item-right-padding: 12px ($item-md-padding-right / 2) 12px
// Material Design Toggle Background Track: Checked
// -----------------------------------------

.toggle-md .toggle-checked {
.toggle-md.toggle-checked .toggle-icon {
background-color: $toggle-md-track-background-color-on;
}

Expand Down
16 changes: 13 additions & 3 deletions src/components/toggle/toggle.wp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ $toggle-wp-item-right-padding: 12px ($item-wp-padding-right / 2) 12px

.toggle-wp {
position: relative;

width: $toggle-wp-track-width;
height: $toggle-wp-track-height;

box-sizing: content-box;

contain: strict;
}


Expand All @@ -82,14 +89,16 @@ $toggle-wp-item-right-padding: 12px ($item-wp-padding-right / 2) 12px
position: relative;
display: block;

width: $toggle-wp-track-width;
height: $toggle-wp-track-height;
width: 100%;
height: 100%;

border: $toggle-wp-track-border-width solid $toggle-wp-track-border-color-off;
border-radius: $toggle-wp-track-height;
background-color: $toggle-wp-track-background-color-off;

pointer-events: none;

contain: strict;
}


Expand All @@ -109,6 +118,8 @@ $toggle-wp-item-right-padding: 12px ($item-wp-padding-right / 2) 12px

transition-duration: $toggle-wp-transition-duration;
transition-property: transform, background-color;

will-change: transform, background-color;
}


Expand All @@ -126,7 +137,6 @@ $toggle-wp-item-right-padding: 12px ($item-wp-padding-right / 2) 12px

.toggle-wp.toggle-checked .toggle-inner {
background-color: $toggle-wp-handle-background-color-on;
// transform: translate3d(23px, 0, 0);
transform: translate3d($toggle-wp-track-width - $toggle-wp-handle-width - ($toggle-wp-track-border-width * 2) - ($toggle-wp-handle-left * 2), 0, 0);
}

Expand Down

0 comments on commit 93d1d02

Please sign in to comment.