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
const math = { | |
map: (x, a, b, c, d) => ((x - a) * (d - c)) / (b - a) + c, | |
lerp: (a, b, n) => (1 - n) * a + n * b | |
}; | |
const { body } = document; | |
// Window | |
let winsize; | |
const calcWinsize = () => { | |
winsize = { width: window.innerWidth, height: window.innerHeight }; |
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
$.fn.isInViewport = function() { | |
const elementTop = $(this).offset().top; | |
const elementBottom = elementTop + $(this).outerHeight(); | |
const viewportTop = $(window).scrollTop(); | |
const viewportBottom = viewportTop + $(window).height(); | |
return elementBottom > viewportTop && elementTop < viewportBottom; | |
}; |
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
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(); | |
} |
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
function createDateAsUTC(date) { | |
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds())); | |
} | |
function convertDateToUTC(date) { | |
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()); | |
} |
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 { useEffect } from 'react'; | |
import { Provider } from 'react-redux'; | |
import { BrowserRouter as Router } from 'react-router-dom'; | |
import { ThemeProvider } from '@material-ui/core/styles'; | |
import CssBaseline from '@material-ui/core/CssBaseline'; | |
import { Routes } from '@/components/Routes'; | |
import { theme } from '@/styles/theme'; | |
import { store } from '@/store/store'; |
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 { useRef, useEffect, useState, useCallback } from 'react'; | |
interface ReturnDataI { | |
ref: React.MutableRefObject<Element | null>; | |
isBottom: boolean; | |
} | |
export function useScrollBottom(offset = 0): ReturnDataI { | |
const ref = useRef<Element>(null); | |
const [isBottom, setIsBottom] = useState<boolean>(false); |
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
export async function getImageUrl(file: File): Promise<string | ArrayBuffer> { | |
return new Promise((resolve) => { | |
import('exif-js') | |
.then((EXIF) => { | |
EXIF.getData(file, function onGetData() { | |
const reader = new FileReader(); | |
reader.onload = ({ target }) => { | |
resolve(target.result); | |
}; | |
reader.readAsDataURL(this); |
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 IMask from 'imask'; | |
export default class Input { | |
constructor(el) { | |
this.el = el; | |
this.input = $.qs('.input__field', this.el); | |
this.isDate = this.input.type === 'date'; | |
this.isPhone = this.input.type === 'tel'; | |
this.isMaskDate = this.input.classList.contains('js-mask-date'); |
NewerOlder