Skip to content

Instantly share code, notes, and snippets.

@feeela
Created June 6, 2014 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feeela/a42fbfcd275d8758d282 to your computer and use it in GitHub Desktop.
Save feeela/a42fbfcd275d8758d282 to your computer and use it in GitHub Desktop.
CSS slide classes for Twitter Bootstrap
/* The slide mixin.
*
* It makes use of Twitter Bootstrap mixins, but those
* are mostly in use for browser compatibility and could
* be rewritten without a TB dependency.
*/
.slide(@distance: 100%, @direction: right) {
.transition-transform( ~"500ms ease-out" );
.slide-to() when (@direction = right) {
&.in {
.translate(@distance,0);
}
}
.slide-to() when (@direction = left) {
&.in {
.translate(-@distance,0);
}
}
.slide-to() when (@direction = top) {
&.in {
.translate(0,-@distance);
}
}
.slide-to() when (@direction = bottom) {
&.in {
.translate(0,@distance);
}
}
.slide-to();
}
/* Use the mixin to create some helper classes… */
.slide.right {
.slide(30rem, right);
}
.slide.left {
.slide(30rem, left);
}
/* Usage:
<div id="page" class="slide right">
<div id="page" class="slide right in">
*/
/* …or use this mixin directly on an existing selector: */
#page {
.slide(30rem, right);
}
/* Usage:
<div id="page">
<div id="page" class="in">
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment