1651의 init
1662 (참고자료: https://velog.io/@bangina/Javascript-코어개념-callapplybind)
this는 401번줄 변수 e임.
this.handlePostMessageResponseBinded = blah;
이런식이면 this에 handlePostMessageResponseBinded 속성 추가 하면서 blah 할당 가능.
(this.handlePostMessageResponseBinded = Function.prototype.bind.call(
this.handlePostMessageResponse,
this
)),
여기서 this.handlePostMessageResponse는
1568번줄 handlePostMessageResponse 함수임.
Function.prototype.bind.call(
this.handlePostMessageResponse,
this
)
call의 두번째 인자 this가
Function.prototype.bind의 인자로 들어감.
call의 첫번째 인자 Function.prototype.bind 내부의 this로 작동함.
------------
this.handlePostMessageResponseBinded에 this.handlePostMessageResponse가 할당되고,
call의 두번째 인자 this가 this.handlePostMessageResponse 내부의 this로 작동함.
즉 앞으로 this.handlePostMessageResponseBinded(xxx)를 사용하면
handlePostMessageResponse(xxx)랑 같음. call 두번째 인자도 this 됐으니까.
this.handlePostMessageResponseBinded가 어디서 호출된건 안보이는데,
e를 리턴해주니까 그쪽에서 쓰겠지 뭐...
355번줄
IIFE(https://findawayer.tistory.com/entry/IIE의-의미는)
!(function (t, e) {
"undefined" != typeof unsafeWindow && null !== unsafeWindow
? unsafeWindow.CTRL_HIDDEN
? t.NOTEPAD.showControlPanel()
: unsafeWindow.NOTEPAD_INIT || ((t.NOTEPAD = e(t)), t.NOTEPAD.init())
: ((void 0 !== t.NOTEPAD && null !== t.NOTEPAD) || (t.NOTEPAD = e(t)),
t.NOTEPAD.controlPanelHidden
? t.NOTEPAD.showControlPanel()
: t.NOTEPAD.initialized || t.NOTEPAD.init());
})("undefined" != typeof window ? window : this, function (v) {
~~
return e;
}
!(function(t, e){})(삼항?ㅇ:ㄴ, function(v){}); 랑 같음.
삼항?ㅇ:ㄴ 결과가 t로 전달
function(v){} 자체가 e로 전달.
!는 그냥 IIFE라는걸 알려주기 위함.
!()(); 앞쪽 function을 정의하는게 아니라 바로 그냥 실행하고 버림.
뒤쪽 괄호 내부가 인자들.
즉, (function(t, e){})(삼항?ㅇ:ㄴ, function(v){}); 랑도 같음.
마우스 움직일 때(마우스모드X 편집모드일 때)
e 내부의 handleMouseMove가 지속적으로 작동함.
handelMouseMove 내부에서 windowToCanvas, setLineProperty가 순서대로 실행됨.
그래서 움직일 때마다 세 함수 로깅됨.
마우스가 캔버스 벗어날 때마다 e 내부의 handleMouseLeave가 실행됨.
펜으로 점찍어보면 (이하 전부 e 내부 함수) handleMouseDown(클릭누르기), handleMouseUp(클릭 손떼기)가 실행되는데 가끔 그리기 좀 오래 안하다가 누르면 사이에 restoreCanvs가 찍힘.
이후 storeCanvas, storeHistory, checkHistoryButtonStatus, addClass, removeClass, handleDragDone, persistLocalStorage가 순서대로 실행.
펜
익스텐션 실행시
팝업에서 툴 선택시