Permalink
Browse files

add scrollToControl

  • Loading branch information...
1 parent 0b16790 commit fb7f84cf8ac3c0c81b5b0df0736328aa41cdaf07 @frankiefu frankiefu committed Apr 2, 2012
Showing with 10 additions and 0 deletions.
  1. +6 −0 source/touch/ScrollStrategy.js
  2. +4 −0 source/touch/Scroller.js
@@ -72,6 +72,12 @@ enyo.kind({
this.setScrollTop(inY);
}
},
+ scrollToControl: function(inControl) {
+ var sb = this.getScrollBounds();
+ var b = inControl.getBounds();
+ this.setScrollTop(Math.min(sb.maxTop, b.top));
+ this.setScrollLeft(Math.min(sb.maxLeft, b.left));
+ },
scrollIntoView: function(inControl, inAlignWithTop) {
if (inControl.hasNode()) {
inControl.node.scrollIntoView(inAlignWithTop);
View
@@ -179,6 +179,10 @@ enyo.kind({
scrollTo: function(inX, inY) {
this.$.strategy.scrollTo(inX, inY);
},
+ //* ensure that the given control is visible in the scroller's viewport. Unlike scrollIntoView which uses DOM's scrollIntoView, this only affects the current scroller.
+ scrollToControl: function(inControl) {
+ this.$.strategy.scrollToControl(inControl);
+ },
// normalize scroll event to onScroll.
scroll: function(inSender, e) {
if (this.$.strategy.scroll) {

0 comments on commit fb7f84c

Please sign in to comment.