Skip to content

Commit

Permalink
fix(slider,slide-toggle): use the grab cursor (#3821)
Browse files Browse the repository at this point in the history
Uses the `grab` cursor when hovering over an active slider's thumb and thumb labels, as well as on active slide toggles.

Fixes #3778.
  • Loading branch information
crisbeto authored and jelbourn committed Apr 11, 2017
1 parent 9490c90 commit cc8f871
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib/core/style/_vendor-prefixes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@
cursor: -webkit-grab;
cursor: grab;
}

@mixin cursor-grabbing {
cursor: -webkit-grabbing;
cursor: grabbing;
}
/* stylelint-enable */
4 changes: 3 additions & 1 deletion src/lib/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg

// Once the thumb container is being dragged around, we remove the transition duration to
// make the drag feeling fast and not delayed.
&.mat-dragging {
&.mat-dragging, &:active {
@include cursor-grabbing;

transition-duration: 0ms;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/lib/slider/slider.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '../core/style/variables';
@import '../core/style/vendor-prefixes';


// This refers to the thickness of the slider. On a horizontal slider this is the height, on a
Expand Down Expand Up @@ -97,7 +98,20 @@ $mat-slider-focus-ring-size: 30px !default;
}
}

%_mat-slider-cursor {
.mat-slider:not(.mat-slider-disabled) & {
@include cursor-grab;
}

.mat-slider:not(.mat-slider-disabled) &:active,
.mat-slider-sliding:not(.mat-slider-disabled) & {
@include cursor-grabbing;
}
}

.mat-slider-thumb {
@extend %_mat-slider-cursor;

position: absolute;
right: -$mat-slider-thumb-size / 2;
bottom: -$mat-slider-thumb-size / 2;
Expand All @@ -113,6 +127,8 @@ $mat-slider-focus-ring-size: 30px !default;
}

.mat-slider-thumb-label {
@extend %_mat-slider-cursor;

display: none;
align-items: center;
justify-content: center;
Expand Down

0 comments on commit cc8f871

Please sign in to comment.