scrollview: fix the scroll position at keydown event
authorMinkyu Kang <mk7.kang@samsung.com>
Thu, 7 Feb 2013 04:37:19 +0000 (13:37 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Thu, 7 Feb 2013 05:53:02 +0000 (14:53 +0900)
When IME is on and input box is hidden,
scroll the view to visible position.
(N_SE-24515)

Change-Id: I408a1af70f2aa09c4e249eab7dd112e34abcc74d

src/widgets/common/js/jquery.mobile.tizen.scrollview.js

index f9f0cf5..30931d2 100644 (file)
 
                scrollTo: function ( x, y, duration ) {
                        this._stopMScroll();
+                       this._didDrag = false;
 
                        if ( !duration || this.options.scrollMethod === "translate" ) {
                                this._setScrollPosition( x, y, duration );
                        $v.bind( "keydown", function ( e ) {
                                var elem,
                                        elem_top,
+                                       scroll_top = $( window ).scrollTop() - window.screenTop,
                                        screen_h;
 
                                if ( e.keyCode == 9 ) {
                                        return;
                                }
 
-                               elem_top = elem.offset().top;
+                               elem_top = elem.offset().top - scroll_top;
                                screen_h = $c.offset().top + $c.height() - elem.height();
 
                                if ( self._softkeyboard ) {
                                        screen_h -= self._softkeyboardHeight;
                                }
 
-                               if ( ( elem_top < 0 ) || ( elem_top > screen_h ) ) {
-                                       self.scrollTo( 0, self._sy - elem_top +
-                                               elem.height() + $c.offset().top, 0);
+                               if ( ( elem_top < $c.offset().top ) || ( elem_top > screen_h ) ) {
+                                       self.scrollTo( 0, self._sy -
+                                                       ( elem_top - $c.offset().top - elem.height() ) );
                                }
 
                                return;
                                var input,
                                        elem,
                                        elem_top,
+                                       scroll_top = $( window ).scrollTop() - window.screenTop,
                                        screen_h;
 
                                if ( e.keyCode != 9 ) {
                                                elem = $( input[i + 1] );
                                        }
 
-                                       elem_top = elem.offset().top + window.screenTop *
-                                               ( $( window ).width() / window.screen.availWidth );
+                                       elem_top = elem.offset().top - scroll_top;
                                        screen_h = $c.offset().top + $c.height() - elem.height();
 
                                        if ( self._softkeyboard ) {