// jQuery
$(document).ready(function() {
// code
})
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
const useWindowSize = () => { | |
// IMPLEMENT | |
const [size, setSize] = useState({width: window.innerWidth, height: window.innerHeight}); | |
useEffect(() => { | |
const eventResize = () => { | |
setSize({width: window.innerWidth, height: window.innerHeight}); | |
} | |
window.addEventListener('resize', eventResize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { | |
background-image: url("@{file-1x}"); | |
@media | |
only screen and (-webkit-min-device-pixel-ratio: 2), | |
only screen and ( min--moz-device-pixel-ratio: 2), | |
only screen and ( -o-min-device-pixel-ratio: 2/1), | |
only screen and ( min-device-pixel-ratio: 2), | |
only screen and ( min-resolution: 192dpi), | |
only screen and ( min-resolution: 2dppx) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.element { | |
position: relative; | |
} | |
/*replace the content value with the | |
corresponding value from the list below*/ | |
.element:before { | |
content: "\f000"; | |
font-family: FontAwesome; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.js-anchor').click(function () { | |
$('html, body').animate({ | |
scrollTop: $($.attr(this, 'href')).offset().top - 50 | |
}, 500); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('html, body').animate({ | |
scrollTop: $("#target-element").offset().top | |
}, 1000); | |
$('a').click(function(){ | |
let href = $(this).attr('href'), | |
elem = $(href).offset().top; | |
$('html, body').animate({scrollTop: elem}, 500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 1 | |
// console.log(value.slice(5, 7)); | |
// if(value.slice(5, 7).includes('67'||'96'||'97'||'68'||'98'||'39'||'50'||'99'||'66'||'95'||'63'||'93'||'73')) { | |
// console.log('yyyyyyyyyyyyyyyyes'); | |
// } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For accept the lazy loading to images you need just add | |
* [data-lazy-src] with a path on image. | |
*/ | |
export default (window.onload = () => { | |
const images = document.querySelectorAll('[data-lazy-src]'); | |
if ('IntersectionObserver' in window) { | |
let observer = new IntersectionObserver( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RIGHT | |
if (window.location.hash) { | |
$('html, body').animate({ | |
scrollTop: $(window.location.hash).offset().top - 50 | |
}, 500); | |
} | |
WRONG | |
// let url = location.href; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('NodeList' in window && !NodeList.prototype.forEach) { | |
console.info('polyfill for IE11'); | |
NodeList.prototype.forEach = function (callback, thisArg) { | |
thisArg = thisArg || window; | |
for (var i = 0; i < this.length; i++) { | |
callback.call(thisArg, this[i], i, this); | |
} | |
}; | |
} |
NewerOlder