Skip to content

Instantly share code, notes, and snippets.

View JLevstein's full-sized avatar

Jonathan Levstein JLevstein

View GitHub Profile
@JLevstein
JLevstein / app.js
Created October 26, 2014 17:46
Basic scrollTo function
$('.primary-nav').on('click', 'a', function(e) {
e.preventDefault();
var target = $(this).attr('href');
var destination = $(target).offset().top;
$('html:not(:animated),body:not(:animated)').stop().animate({
scrollTop: destination - 60
}, 600);
return true;
});
<div class="center-contain">
<div class="center-this"> Everything in this div will be centered in IE8 or greater</div>
</div>
/* From Modernizr */
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd',
'MsTransition':'msTransitionEnd'
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle:"",cursor:"move"}, opt);
if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $http, $cacheFactory) {
// using $cacheFactory to make sure we clear
// the cache and then re-set it when cache is false
// in $scope.makeRequest
var httpCache = $cacheFactory.get('$http');
$scope.makeRequest = function (cache) {
if(!cache) httpCache.remove('response.php');
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-ms-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
var sidekicks = [
{ name: "Robin", hero: "Batman" },
{ name: "Supergirl", hero: "Superman" },
{ name: "Oracle", hero: "Batman" },
{ name: "Krypto", hero: "Superman" }
];
var batKicks = sidekicks.filter(function (el) {
return (el.hero === "Batman");
});
@JLevstein
JLevstein / jQuery - Reload part of page
Created August 31, 2013 23:08
jQuery - Reload part of page
setInterval(function() {   $(“#block”).load(location.href+”#block>*”,””);  }, 2000);