Skip to content

Instantly share code, notes, and snippets.

View Dexdot's full-sized avatar
🏠
Working from home

Kam Dexdot

🏠
Working from home
View GitHub Profile
@Dexdot
Dexdot / datediff.js
Created May 5, 2018 08:20
Date difference
class DateDiff {
constructor(date1, date2) {
this.days = null;
this.hours = null;
this.minutes = null;
this.seconds = null;
this.date1 = date1;
this.date2 = date2;
this.init();
}
@Dexdot
Dexdot / three.js
Created May 1, 2018 19:48
Three.js base setup
import * as THREE from 'three';
const OrbitControls = require('three-orbit-controls')(THREE);
let camera,
controls,
scene,
renderer,
mesh,
time = 0;
@Dexdot
Dexdot / textareaAutosize.js
Last active April 8, 2018 11:25
Textarea autosize (height content)
$('.container').on('change keyup keydown paste cut', 'textarea', function() {
$(this).height(0).height(this.scrollHeight);
}).find('textarea').change();
@Dexdot
Dexdot / preloader.js
Created December 18, 2017 15:41
preloader script
window.onload = function() {
var el = document.querySelector('.preloader-wrap');
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= 0.03) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
@Dexdot
Dexdot / fadeOut.js
Created December 18, 2017 11:12
fadeOut vanilla js
function fadeOut(el) {
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= 0.03) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
@Dexdot
Dexdot / gist:3967d292ccadf8231899625a5a6971d8
Created November 29, 2017 12:29
timer - day/hour/min/sec before the date
function fulltime () {
var time = new Date();
var newYear = new Date("January,1,2018,00:00:00");
var totalRemains = (newYear.getTime()-time.getTime());
if (totalRemains > 1) {
var RemainsSec = (parseInt(totalRemains / 1000));//сколько всего осталось секунд
var RemainsFullDays = (parseInt(RemainsSec / (24*60*60)));//осталось дней
var secInLastDay = RemainsSec-RemainsFullDays*24*3600; //осталось секунд в неполном дне
var RemainsFullHours = (parseInt(secInLastDay / 3600));//осталось часов в неполном дне
@Dexdot
Dexdot / yt jsapi stopVideo
Created October 18, 2017 20:38
youtube jsapi stopvideo
$(this)[0].contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*')
@font-face {
font-family: 'Proxima Nova Rg';
src: url('../../prod/fonts/proxima/ProximaNova-Bold.woff2') format('woff2'),
url('../../prod/fonts/proxima/ProximaNova-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Proxima Nova Rg';
@Dexdot
Dexdot / yandex map
Created September 13, 2017 20:38
custom yandex map
<!-- Подключаем API Яндекс карт внутри тега head -->
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<!-- Создаем div с id map в теле документа bofy -->
<div id="map" style="width: 100%; height: 400px"></div>
<!-- Настраиваем карту через JavaScript -->
<script type="text/javascript">
//создаем переменные "Карта" и "Метка"
ymaps.ready(init);
@Dexdot
Dexdot / ytb-rspnsv-2
Created September 13, 2017 17:02
Responsive YouTube #2 variant
&__video {
width: 100%;
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
iframe {
position: absolute;
top: 0;
left: 0;