Skip to content

Instantly share code, notes, and snippets.

View JoanClaret's full-sized avatar

Joan Claret JoanClaret

  • Adevinta
  • Barcelona
View GitHub Profile
@JoanClaret
JoanClaret / SASS-breakpoints-mixin.scss
Last active August 29, 2015 14:14
SASS breakpoints mediaqueries mixin
//------------------------------------------
// Breakpoints and media queries mixin
//------------------------------------------
//
// Usage:
//------------------------------------------
//
// @include breakpoint($breakpoint, $query1) {
// /* Styles */
// }
@JoanClaret
JoanClaret / Sticky-layer.js
Last active August 29, 2015 14:14
Sticky layer
$(function() {
var $el = $('.sticky-layer');
var $window = $(window);
$window.bind("scroll resize", function() {
var elHeight = $el.outerHeight();
var windowHeight = $window.height();
var scrolledHeight = $window.scrollTop();
if ((windowHeight + scrolledHeight) > elHeight ){
@JoanClaret
JoanClaret / unknow-height-animate.js
Last active August 29, 2015 14:14
Animate to an unknown height with jquery
$(document).ready(function(){
$('.js-show').click(function(){
var id = $(this).attr('id');
var el = $('.' + id);
if ($(this).hasClass('open')){
el.animate({height: '46px'}, 600);
}
else{
@JoanClaret
JoanClaret / npm Install --no-bin-link
Created February 9, 2015 15:14
npm install --no-bin-link (for windows/ubuntu shared folders)
@JoanClaret
JoanClaret / Make-all-div-clickable-with-CSS.html
Last active August 29, 2015 14:15
Make all div clickable with CSS using absolute positioning
<h1>Make all div clickable with CSS <span>using absolute positioning</span></h2>
<div>
<a href="https://github.com/JoanClaret/" title="Github link">Github link</a>
<h2>Joan's Github</h2>
<p>Mixtape blog readymade, pork belly DIY sriracha hoodie. Cred gentrify freegan, swag DIY 90's tilde tousled listicle Thundercats. Seitan taxidermy Helvetica Blue Bottle, slow-carb Tumblr letterpress ugh plaid Thundercats mlkshk.
</p>
</div>
@JoanClaret
JoanClaret / quojs.js
Last active August 29, 2015 14:15
Quojs: Open / Close sidebar navigation by swipe
var $swipeable = $$('nav');
var first = true;
var locked = false;
var direction;
$swipeable.swipe(function(e) {
// after swipe, reinitialize control variables
first = true;
@JoanClaret
JoanClaret / Simple-javascript-encapsulation.js
Created February 19, 2015 11:49
Simple Javascript encapsulation
var linkcolor = (function(selector, $){
$(selector).click(function(e){
// console.log($(this)); // display target element
// console.log(e); // display event information
// console.log(e.clientX); // display event property value
// console.log(e.target); // display event property value
if ($(this).hasClass('active')){
@JoanClaret
JoanClaret / Multiple-javascript-encapsulation.js
Last active August 29, 2015 14:15
Multiple javascript encapsulation examples
// define components function
var components = (function($$) {
// define linkcolor function in components context
var linkColor = function(selector){
$(selector).click(function(e){
if ($$(this).hasClass('link-blue')){
console.log($$(this).attr('title'));
"use strict";
var myClosure = (function outerFunction() {
var hidden = 1;
return {
inc: function innerFunction() {
return hidden++;
}
@JoanClaret
JoanClaret / gulpfile.js
Created February 16, 2016 13:24
send variable to gulp
var isProduction = true;
if(gutil.env.production === true) {
isProduction = true;
}
gulp.task('sass-private', function () {
return gulp.src('resources/assets/scss/styles-private.scss')
.pipe(plumber({errorHandler: onError}))