Skip to content

Instantly share code, notes, and snippets.

@ingowennemaring
ingowennemaring / accordion
Created August 22, 2015 23:53
Script for an simple accordion
( function ( sR, $ ) {
sR.ACCORDION = {
// set the default options
//defaults: {},
init: function ( /*options*/) {
@ingowennemaring
ingowennemaring / touchActionOnSecondTap
Created August 12, 2015 11:10
trigger action on second tap
function touchActionOnSecondTap ( oElem ) {
oElem.on(
'touchend',
function ( e ) {
var elem = $( this );
if ( elem.data( 'clicked_once' ) ) {
// element has been tapped (hovered), reset 'clicked_once' data flag and return true
elem.data( 'clicked_once', false );
@ingowennemaring
ingowennemaring / isOnScreen
Created August 6, 2015 15:59
Check if an element is in the viewport
( function ( $ ) {
$.fn.isOnScreen = function () {
var win = $( window ),
bounds = this.offset(),
viewport = {
top: win.scrollTop(),
left: win.scrollLeft()
};
@ingowennemaring
ingowennemaring / cssAni
Created August 6, 2015 15:54
Trigger css animations via JavaScript
function cssAni ( mode, elem ) {
var show = function () {
// timeout nötig für Fx => sonst kein transition-Event
setTimeout( function () {
elem.addClass( 'transition visible' );
}, 100 );
};
@ingowennemaring
ingowennemaring / supports
Created August 6, 2015 15:46
Check if a browser supports a feature
function supports ( prop ) {
var div = document.createElement( 'div' ),
vendors = 'Khtml Ms O Moz Webkit'.split( ' ' ),
len = vendors.length;
if ( prop in div.style ) {
return true;
}
@ingowennemaring
ingowennemaring / getScrollbarWidth
Created July 31, 2013 12:26
Get the width of the scrollbar
function getScrollbarWidth() {
var scrollbarWidth,
scrollDiv = $('<div />')
.css({
width: '100%',
height: '100%',
overflow: 'scroll',
position: 'absolute',
top: '-9999px'
@ingowennemaring
ingowennemaring / ishomescreen.js
Created April 22, 2013 09:02
Check if website is added to the home screen or opened in mobile safari
if(navigator.standalone === undefined || !!navigator.standalone) {
// if added to home screen do this
} else {
// if opened in mobile safari do this
}
@ingowennemaring
ingowennemaring / config.rb
Last active December 16, 2015 10:29
Typical config.rb for Compass
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "css"
images_dir = "img"
javascripts_dir = "js"
fonts_dir = "fonts"
@ingowennemaring
ingowennemaring / _reset.scss
Last active December 16, 2015 10:19
Resetting and normalizing
/* inspired by Boilerplate, Normalize.css and own thinking :-) */
/* @group BASE */
* {
position: relative;
margin: 0;
padding: 0;
//outline: 0 none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
@ingowennemaring
ingowennemaring / _mixins.scss
Last active December 16, 2015 10:19
Mixins & Extends
/* @group Mixins */
@mixin box-sizing($sizing: content-box) {
-webkit-box-sizing: $sizing;
-moz-box-sizing: $sizing;
box-sizing: $sizing;
}
@mixin rotate($rotate: -90deg) {
-webkit-transform: rotate($rotate);