naver / egjs

Javascript components group that brings easiest and fastest way to build a web application in your way.
https://naver.github.io/egjs
Other
935 stars 80 forks source link

Rotate event is not fired In certain cases. (eg.isPortrait() issue) #182

Closed woosh80 closed 8 years ago

woosh80 commented 8 years ago

Description

egjs 1.1.0 rotate event is not fired In certain cases

When attach ‘resize' events which check the 'eg.isPortrait()' rotate event is not fired.

On first resize event, isPortrait(=isVertical) method update values of beforeVertical, beforeScreenWidth, beforeScreenHeight. Then on fired rotate event, isVertical method compare with these already changed values, so the result of (beforeVertical !== currentVertical) on triggerRotate method is always false and it’s why rotate event not fire.

It seems that isPortrait method have to get the result without reset before values. Check this issue plz.

Steps to check or reproduce

$el.on(‘resize’, function() { if (eg.isPortrait()) { do something… } });

$el.on(‘rotate’, function() { console.log(‘rotate event fired.’); });

image image image

jongmoon commented 8 years ago

@mixed

I have a question on rotate test case. isVertical : If event is resize then second times call. and stay.

Can you tell me the reason why isVertical must returns null (last lines) on below case? Is it right for isVertical to have have true?

var fakeDocument = {
  "documentElement" : {
  "clientWidth" : 100,
  "clientHeight" : 200
  }
};

var method = eg.invoke("rotate",[jQuery, null, fakeWindow, fakeDocument]);
method.isVertical();

// When
fakeDocument.documentElement.clientWidth =  100;
fakeDocument.documentElement.clientHeight =  200;
var isVertical = method.isVertical();

// Then
equal(isVertical,null);