Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
hint.css/src/hint-position.scss
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
138 lines (115 sloc)
2.69 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* source: hint-position.scss | |
* | |
* Defines the positoning logic for the tooltips. | |
* | |
* Classes added: | |
* 1) hint--top | |
* 2) hint--bottom | |
* 3) hint--left | |
* 4) hint--right | |
*/ | |
@mixin vertical-positioned-tooltip($propertyY, $transitionDirection, $xDirection:0) { | |
&:before { | |
// bring arrow inside so that it animates to normal position when shown. | |
// HACK: +1px to avoid the 1 px white space between arrow and body during transition. | |
margin-#{$propertyY}: -2 * $hintArrowBorderWidth + 1px; | |
} | |
&:before, &:after { | |
#{$propertyY}: 100%; | |
left: 50%; // get top-left corner in center | |
} | |
&:before { | |
left: calc(50% - #{$hintArrowBorderWidth}); // get arrow center aligned with content | |
} | |
$translateX: -50%; | |
@if $xDirection == -1 { | |
$translateX: -100%; | |
} @else if $xDirection == 1 { | |
$translateX: 0; | |
} | |
&:after { | |
@include vendor('transform', translateX($translateX)); | |
} | |
&:after { | |
@if $xDirection != 0 { | |
// bring back the tooltip by some offset so that arrow doesn't stick at end | |
margin-left: -$xDirection * $hintArrowOffsetX; | |
} | |
} | |
&:hover { | |
@include set-margin('translateY', $transitionDirection, $translateX); | |
} | |
} | |
@mixin horizontal-positioned-tooltip($propertyX, $transitionDirection) { | |
&:before { | |
// bring arrow inside so that it animates to normal position when shown | |
// HACK: +1px to avoid the 1 px white space between arrow and body during transition. | |
margin-#{$propertyX}: -2 * $hintArrowBorderWidth + 1px; | |
// bring back to center vertically | |
margin-bottom: -1 * $hintArrowBorderWidth; | |
} | |
&:after { | |
// bring back to center | |
margin-bottom: -1 * floor($hintTooltipHeight / 2); | |
} | |
&:before, &:after { | |
#{$propertyX}: 100%; | |
bottom: 50%; | |
} | |
&:hover { | |
@include set-margin('translateX', $transitionDirection); | |
} | |
} | |
/** | |
* set default color for tooltip arrows | |
*/ | |
@include arrow-border-color($hintDefaultColor); | |
/** | |
* top tooltip | |
*/ | |
.#{$hintPrefix}top { | |
@include vertical-positioned-tooltip('bottom', -1); | |
} | |
/** | |
* bottom tooltip | |
*/ | |
.#{$hintPrefix}bottom { | |
@include vertical-positioned-tooltip('top', 1); | |
} | |
/** | |
* right tooltip | |
*/ | |
.#{$hintPrefix}right { | |
@include horizontal-positioned-tooltip('left', 1); | |
} | |
/** | |
* left tooltip | |
*/ | |
.#{$hintPrefix}left { | |
@include horizontal-positioned-tooltip('right', -1); | |
} | |
/** | |
* top-left tooltip | |
*/ | |
.#{$hintPrefix}top-left { | |
@include vertical-positioned-tooltip('bottom', -1, -1); | |
} | |
/** | |
* top-right tooltip | |
*/ | |
.#{$hintPrefix}top-right { | |
@include vertical-positioned-tooltip('bottom', -1, 1); | |
} | |
/** | |
* bottom-left tooltip | |
*/ | |
.#{$hintPrefix}bottom-left { | |
@include vertical-positioned-tooltip('top', 1, -1); | |
} | |
/** | |
* bottom-right tooltip | |
*/ | |
.#{$hintPrefix}bottom-right { | |
@include vertical-positioned-tooltip('top', 1, 1); | |
} |