Export 0.1.47
[framework/web/web-ui-fw.git] / src / widgets / common / js / jquery.mobile.tizen.scrollview.js
index 6bc7f04..5ac74de 100644 (file)
@@ -35,7 +35,7 @@
        };
 
        function getCurrentTime() {
-               return ( new Date() ).getTime();
+               return Date.now();
        }
 
        jQuery.widget( "tizen.scrollview", jQuery.mobile.widget, {
                        scrollJump:        false,
                },
 
+               _getViewHeight: function () {
+                       return this._$view.height() + this._view_offset;
+               },
+
                _makePositioned: function ( $ele ) {
                        if ( $ele.css("position") === "static" ) {
                                $ele.css( "position", "relative" );
@@ -69,8 +73,7 @@
                },
 
                _create: function () {
-                       var $page = $('.ui-page'),
-                               direction,
+                       var direction,
                                self = this;
 
                        this._$clip = $( this.element ).addClass("ui-scrollview-clip");
@@ -88,7 +91,9 @@
 
                        this._makePositioned( this._$view );
                        this._$view.css( { left: 0, top: 0 } );
-                       this._view_height = this._$view.height();
+
+                       this._view_offset = this._$view.offset().top - this._$clip.offset().top;
+                       this._view_height = this._getViewHeight();
 
                        this._sx = 0;
                        this._sy = 0;
 
                        if ( vt ) {
                                c = this._$clip.height();
-                               v = this._$view.height() +
-                                       parseFloat( this._$view.css("padding-top") );
+                               v = this._getViewHeight();
 
                                vt.start( this._sy, speedY,
                                        duration, (v > c) ? -(v - c) : 0, 0 );
                        }
 
                        if ( dirLock !== "x" && this._vTracker ) {
-                               scroll_height = $v.height() - $c.height() +
-                                       parseFloat( $c.css("padding-top") ) +
-                                       parseFloat( $c.css("padding-bottom") );
+                               scroll_height = this._getViewHeight() - $c.height();
 
                                this._outerScroll( y, scroll_height );
 
 
                        this._setCalibration( x, y );
 
-                       if ( this._outerScrolling ) {
-                               return;
-                       }
-
                        x = this._sx;
                        y = this._sy;
 
 
                                if ( sm === "translate" ) {
                                        this._setElementTransform( $sbt, "0px",
-                                               -y / $v.height() * $sbt.parent().height() + "px",
+                                               -y / this._getViewHeight() * $sbt.parent().height() + "px",
                                                duration );
                                } else {
-                                       $sbt.css( "top", -y / $v.height() * 100 + "%" );
+                                       $sbt.css( "top", -y / this._getViewHeight() * 100 + "%" );
                                }
                        }
 
                                        target.is( '.ui-btn-inner' ) ||
                                        target.is( '.ui-btn-inner .ui-icon' );
 
+                       if ( this._is_button ) {
+                               if ( target.parents('.ui-slider-handle') ) {
+                                       this._skip_dragging = true;
+                                       return;
+                               }
+                       }
+
                        /*
                         * We need to prevent the default behavior to
                         * suppress accidental selection of text, etc.
                        }
 
                        $c.bind( "updatelayout", function ( e ) {
-                               var $page = $c.parentsUntil("ui-page"),
-                                       sy,
-                                       vh;
+                               var sy,
+                                       vh,
+                                       view_h = self._getViewHeight();
 
-                               if ( !$c.height() || !$v.height() ) {
+                               if ( !$c.height() || !view_h ) {
                                        self.scrollTo( 0, 0, 0 );
                                        return;
                                }
 
-                               sy = $c.height() - $v.height();
-                               vh = $v.height() - self._view_height;
+                               sy = $c.height() - view_h;
+                               vh = view_h - self._view_height;
 
-                               self._view_height = $v.height();
+                               self._view_height = view_h;
 
                                if ( vh == 0 || vh > $c.height() / 2 ) {
                                        return;
                        });
 
                        $( window ).bind( "resize", function ( e ) {
-                               var $page = $c.parentsUntil("ui-page"),
-                                       focused;
+                               var focused,
+                                       view_h = self._getViewHeight();
 
-                               if ( !$c.height() || !$v.height() ) {
+                               if ( $(".ui-page-active").get(0) !== self._page.get(0) ) {
+                                       return;
+                               }
+
+                               if ( !$c.height() || !view_h ) {
                                        return;
                                }
 
                                        focused.trigger("resize.scrollview");
                                }
 
-                               /* calibration */
-                               if ( self._sy < $c.height() - $v.height() ) {
-                                       self.scrollTo( 0, self._sy,
-                                               self.options.snapbackDuration );
-                               }
+                               /* calibration - after triggered throttledresize */
+                               setTimeout( function () {
+                                       if ( self._sy < $c.height() - self._getViewHeight() ) {
+                                               self.scrollTo( 0, self._sy,
+                                                       self.options.snapbackDuration );
+                                       }
+                               }, 260 );
+
+                               self._view_height = view_h;
+                       });
 
-                               self._view_height = $v.height();
+                       $( document ).one( "pageshow", function ( e ) {
+                               self._page = $(".ui-page-active");
+                               self._view_offset = self._$view.offset().top - self._$clip.offset().top;
+                               self._view_height = self._getViewHeight();
                        });
                },
 
 
                        if ( this._vTracker ) {
                                ch = $c.height();
-                               vh = $v.height();
+                               vh = this._getViewHeight();
                                this._maxY = ch - vh;
 
                                if ( this._maxY > 0 ) {