naver / egjs-axes

A module used to change the information of user action entered by various input devices such as touch screen or mouse into the logical virtual coordinates.
https://naver.github.io/egjs-axes/
MIT License
179 stars 31 forks source link

Coordinate.ts - getInsidePosition #41

Closed hikaMaeng closed 7 years ago

hikaMaeng commented 7 years ago

According to the unit test(https://goo.gl/G2kNn6), range param is given as [start, end] and always start <end. therefore No need to iterate the algorithm in the return statement.

current code

  toDestPos = Math.max(targetRange[0], toDestPos);
  toDestPos = Math.min(targetRange[1], toDestPos);
return +Math.min(targetRange[1], Math.max(targetRange[0], toDestPos)).toFixed(5);

recommand

  toDestPos = Math.max(targetRange[0], toDestPos);
  toDestPos = Math.min(targetRange[1], toDestPos);
return +toDestPos.toFixed(5);
sculove commented 7 years ago

Thanks. Could you give me a pr please?

hikaMaeng commented 7 years ago

I'll try.. I didn't yet set local environment for egjs ^^;