Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created September 22, 2014 17:12
Show Gist options
  • Save uhtred/743a9387968722331014 to your computer and use it in GitHub Desktop.
Save uhtred/743a9387968722331014 to your computer and use it in GitHub Desktop.
CSS: Detect Viewport Change
/*
Based on: http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/
*/
body {
@include animation-duration( 0.001s );
@media screen and (min-width: 48em) {
@include animation-name( mq-gt-md );
}
@media screen and (max-width: 48em ) {
@include animation-name( mq-lt-md );
}
}
@include keyframes( mq-gt-md ) {
from { clip: rect(1px, auto, auto, auto); }
to { clip: rect(0px, auto, auto, auto); }
}
@include keyframes( mq-lt-md ) {
from { clip: rect(1px, auto, auto, auto); }
to { clip: rect(0px, auto, auto, auto); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment