npm i mkt-util
- animate(Function) : 반복할 함수
- [fps=60](Number) : 초당 프레임 수
const animation1 = new AnimationFrame(() => {
console.log('test')
});
//animation start
animation1.start();
//animation stop
animation1.stop();
(String): 브라우저 이름
const browser = getBrowser();
(String): 디바이스 종류 ('pc' or 'mobile')
const browser = getDevice();
css 파일을 lazy load 하고 콜백 함수를 실행 합니다.
- src(String) : 불러올 css 파일 경로
- [callback](Function) : 콜백함수
loadCss('https://wstatic-cdn.plaync.com/promo/app.css', () => {
console.log('loaded css')
})
js 파일을 lazy load 하고 콜백 함수를 실행 합니다.
- src(String) : 불러올 js 파일 경로
- [callback](Function) : 콜백함수
loadJs('https://wstatic-cdn.plaync.com/promo/app.js', () => {
console.log('loaded js')
})
문장 공백을 제거 합니다.
- url(String) : 문장
- [removeAll = false](Boolean) : 전체 공백 제거 유무
(String): 공백이 제거된 문자열
console.log(trim(' 안 녕 하 세 요! '))
// => '안 녕 하 세 요!'
console.log(trim(' 안 녕 하 세 요!', true))
// => '안녕하세요!'
마우스 휠 방향을 체크 합니다.
- mouse wheel event
(Number) : up: -1 , down: 1
$(window).on('mousewheel DOMMouseScroll', (e) => {
console.log(wheelDirection(e))
// => -1 or 1
});
const emitter = new Emitter();
emitter.on('play pause', () => {
});
emitter.on('mute', () => {
});
emitter.emit('play');
emitter.emit('pause');
emitter.emit('mute', {type: 'mute'});