sproutcore / sproutcore

JavaScript Application Framework - JS library only
sproutcore.com
Other
2.15k stars 291 forks source link

ScrollView offset after resizing parent view #1299

Closed s-faychatelard closed 9 years ago

s-faychatelard commented 9 years ago

I'm having a strange issue with the latest 1.11.0.rc1, when resizing the parent of the scrollView with adjust the horizontalScrollOffset and verticalScrollOffset aren't recalculated directly. I have to scroll a bit.

Here is some UT to expose the problem, hope they will be helpful (written tests/views/scroll/methods.js)

SC.run(function () {
  view.scrollBy(3900, 3900);
  pane.adjust({ width: 64, height: 64 });
  equals(view.get('horizontalScrollOffset'), view.get('maximumHorizontalScrollOffset'), "After resizing the pane with adjust height of 64, horizontal offset must be maximum");
  equals(view.get('verticalScrollOffset'), view.get('maximumVerticalScrollOffset'), "After resizing the pane with adjust width of 64, vertical offset must be maximum");
  pane.adjust({ width: 114, height: 114 });
});

SC.run(function () {
  view.scrollBy(3900, 3900);
  pane.adjust({ width: 1014, height: 1014 });
  equals(view.get('horizontalScrollOffset'), view.get('maximumHorizontalScrollOffset'), "After resizing the pane with adjust height of 1014, horizontal offset must be maximum");
  equals(view.get('verticalScrollOffset'), view.get('maximumVerticalScrollOffset'), "After resizing the pane with adjust width of 1014, vertical offset must be maximum");
  pane.adjust({ width: 114, height: 114 });
});
publickeating commented 9 years ago

Hi, Thanks a lot for pointing this out.

I worked on this and came up with what I believe are the proper scenarios (depending on the value of horizontalAlign and verticalAlign). I extended your tests (thanks) to ensure each scenario is covered. Please check out this commit: https://github.com/sproutcore/sproutcore/commit/dc97727ca716d7c81c591834ca483a451aee634a

s-faychatelard commented 9 years ago

Thanks a lot, works like a charm