Skip to content

Instantly share code, notes, and snippets.

@panicbus
panicbus / even-more-mixins.scss
Created October 20, 2016 18:39
Even More Handy Sass Mixins
// Set all transitions across browsers
@mixin transition($property: all, $duration: .4s, $easing: ease-in-out) {
-webkit-transition: $property, $duration, $easing;
-moz-transition: $property, $duration, $easing;
-ms-transition: $property, $duration, $easing;
-o-transition: $property, $duration, $easing;
transition: $property, $duration, $easing;
}
// Set drop shadows on elements
@panicbus
panicbus / window-visible.js
Created October 20, 2016 18:39
Fade in element on window visible
$(document).ready(function() {
$(window).scroll( function(){
$('.scrollEffect').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height() + 200;
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'opacity':'1', 'top':'0px'},500);
@panicbus
panicbus / bouncein-fadein.scss
Created October 20, 2016 18:38
.bounceIn .fadeIn
// FADE IN
// add .fadeIn class to element
@-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@panicbus
panicbus / numbering.html
Last active March 2, 2017 20:49
Create a numbered table list in Angular
// http://stackoverflow.com/questions/29091830/auto-numbering-of-angularjs-ng-repeat-list
// # | Name of student | Student ID
// _________________________________
// 1 | Samuel Addo | 346578
// 2 | GRace Asumani | 965433
// 3 | Zein Akill | 123455
// 4 | David Addoteye | 678543
{{$index +1}}
@panicbus
panicbus / main.scss
Created October 20, 2016 18:37
How to import partial files for compiling
// Globals and Variables //
// Import Sass from files in the globals folder (no underscore)
@import "globals/colors";
@import "globals/typography";
@import "globals/declarations";
@import "globals/base";
// Components //
// Import Sass from the files in the components folder.
// Make sure any custom components files you add are represented here,
@panicbus
panicbus / more-handy-sass-mixins.scss
Created October 20, 2016 18:36
More handy sass mixins
// Set all transitions across browsers
@mixin transition($property: all, $duration: .4s, $easing: ease-in-out) {
-webkit-transition: $property, $duration, $easing;
-moz-transition: $property, $duration, $easing;
-ms-transition: $property, $duration, $easing;
-o-transition: $property, $duration, $easing;
transition: $property, $duration, $easing;
}
// Set drop shadows on elements
@panicbus
panicbus / rem-size.scss
Created October 20, 2016 18:36
Calculate REM size with Sass
// Take a px and convert to rem
@function calculateRem($values) {
@if $supports-rem {
$max: length($values);
@if $max == 1 { @return convert-to-rem(nth($values, 1)); }
$remValues: ();
@for $i from 1 through $max {
@panicbus
panicbus / breakpoints.scss
Created October 20, 2016 18:35
SASS breakpoint declarations for various screen sizes
// MEDIA QUERY RANGES
$x-small-range: (0, 27em) !default; // 432px - used only for checkout steps because of text wrapping
$small-range: (0, 47.49em) !default; // 759px
$medium-range: (47.5em, 59.99em) !default; // 760 - 959px
$large-range: (60em, 99999999em) !default; // 960px up
$screen: "only screen" !default;
$landscape: "#{$screen} and (orientation: landscape)" !default;
$portrait: "#{$screen} and (orientation: portrait)" !default;
$x-small-only: "#{$screen} and (max-width: #{upper-bound($x-small-range)})" !default;
$small-up: $screen !default;
@panicbus
panicbus / hover-delay.js
Created October 20, 2016 18:34
Script to create a little delay when mousing on/off an hover-only element to prevent the annoying accidental hover state
var setTimeoutDelay;
$('.myDropdown').mouseover(function(){
setTimeoutDelay = setTimeout(function(){
$('.myDropdown-expanded').show();
$('.myDropdown-header').addClass('myDropdown-hover');
}, 300);
}).mouseout(function(){
clearTimeout(setTimeoutDelay);
setTimeout(function(){
var isHover = $('.myDropdown-expanded').is(':hover');
@panicbus
panicbus / callbacks.js
Last active March 1, 2017 23:34
Callbacks
// run the initial function
function greet(callback) {
console.log('Hey!');
// you can include objects in your callback
var data = {
name: 'Piper'
};
// then run a callback to run the callback function
// which will add the callback functions as parameters on the main function
callback(data);