-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add size parameter for animated link (#51)
- Loading branch information
1 parent
2f2a502
commit 79e6e5f
Showing
2 changed files
with
31 additions
and
15 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,55 @@ | ||
$animatedLinkColor: currentColor !default; | ||
$animatedLinkSize: 0.1em !default; | ||
$animatedLinkSpeed: 0.25s !default; | ||
$animatedLinkExistKeyframes: (); | ||
|
||
@mixin animatedLink($color: $animatedLinkColor) { | ||
@function animatedKeyFrameName($size) { | ||
@return linkHover#{$size * 10000}; | ||
} | ||
|
||
@mixin animatedLinkKeyFrames($size) { | ||
@if not map-has-key($animatedLinkExistKeyframes, $size) { | ||
@keyframes #{animatedKeyFrameName($size)} { | ||
0% { | ||
background-size: 0 $size; | ||
} | ||
|
||
100% { | ||
background-size: 100% $size; | ||
} | ||
} | ||
} | ||
|
||
$animatedLinkExistKeyframes: map-merge($animatedLinkExistKeyframes, ($size: $size)) !global; | ||
} | ||
|
||
@mixin animatedLink($color: $animatedLinkColor, $size: $animatedLinkSize) { | ||
background-image: linear-gradient($color, $color); | ||
background-position: left bottom; | ||
background-repeat: no-repeat; | ||
background-size: 100% $animatedLinkSize; | ||
background-size: 100% $size; | ||
|
||
&:hover, | ||
&:focus { | ||
animation-duration: $animatedLinkSpeed; | ||
animation-name: linkHover; | ||
animation-name: animatedKeyFrameName($size); | ||
} | ||
|
||
@include animatedLinkKeyFrames($size); | ||
} | ||
|
||
@mixin animatedLinkHover($color: $animatedLinkColor) { | ||
@mixin animatedLinkHover($color: $animatedLinkColor, $size: $animatedLinkSize) { | ||
background: none; | ||
|
||
&:hover, | ||
&:focus { | ||
animation-duration: $animatedLinkSpeed; | ||
animation-name: linkHover; | ||
animation-name: animatedKeyFrameName($size); | ||
background-image: linear-gradient($color, $color); | ||
background-position: left bottom; | ||
background-repeat: no-repeat; | ||
background-size: 100% $animatedLinkSize; | ||
} | ||
} | ||
|
||
@keyframes linkHover { | ||
0% { | ||
background-size: 0 $animatedLinkSize; | ||
background-size: 100% $size; | ||
} | ||
|
||
100% { | ||
background-size: 100% $animatedLinkSize; | ||
} | ||
@include animatedLinkKeyFrames($size); | ||
} |