No need to set thumb position if scroll bar isn;t visible and stop scroll value from going negative (bad things can happen)
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/cf660e84 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/cf660e84 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/cf660e84 Branch: refs/heads/release4.12.0 Commit: cf660e8408c0c4d7219889ea66ed6df4bcc12f71 Parents: eb34243 Author: Justin Mclean <[email protected]> Authored: Mon Feb 17 18:20:31 2014 +1100 Committer: Justin Mclean <[email protected]> Committed: Mon Feb 17 18:20:31 2014 +1100 ---------------------------------------------------------------------- .../spark/src/spark/components/HScrollBar.as | 21 ++++++++------- .../spark/src/spark/components/VScrollBar.as | 27 +++++++++++--------- 2 files changed, 27 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/cf660e84/frameworks/projects/spark/src/spark/components/HScrollBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/components/HScrollBar.as b/frameworks/projects/spark/src/spark/components/HScrollBar.as index ca8d456..b06bfcb 100644 --- a/frameworks/projects/spark/src/spark/components/HScrollBar.as +++ b/frameworks/projects/spark/src/spark/components/HScrollBar.as @@ -323,17 +323,20 @@ public class HScrollBar extends ScrollBarBase thumbPosTrackX = trackSize - thumbSize; } - if (!fixedThumbSize) - thumb.setLayoutBoundsSize(thumbSize, NaN); if (getStyle("autoThumbVisibility") === true) thumb.visible = thumbSize < trackSize; - // convert thumb position to parent's coordinates. - thumbPos = track.localToGlobal(new Point(thumbPosTrackX, 0)); - if (thumb.parent) - thumbPosParentX = thumb.parent.globalToLocal(thumbPos).x; - - thumb.setLayoutBoundsPosition(Math.round(thumbPosParentX), thumb.getLayoutBoundsY()); + if (thumb.visible) { + if (!fixedThumbSize) + thumb.setLayoutBoundsSize(thumbSize, NaN); + + // convert thumb position to parent's coordinates. + thumbPos = track.localToGlobal(new Point(thumbPosTrackX, 0)); + if (thumb.parent) + thumbPosParentX = thumb.parent.globalToLocal(thumbPos).x; + + thumb.setLayoutBoundsPosition(Math.round(thumbPosParentX), thumb.getLayoutBoundsY()); + } } /** @@ -517,7 +520,7 @@ public class HScrollBar extends ScrollBarBase { // SDK-28898: reverted previous behavior for desktop, resets // scroll position to zero when all content is removed. - maximum = viewport.contentWidth - viewport.width; + maximum = Math.max(0, viewport.contentWidth - viewport.width); } } } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/cf660e84/frameworks/projects/spark/src/spark/components/VScrollBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/components/VScrollBar.as b/frameworks/projects/spark/src/spark/components/VScrollBar.as index a8afadb..c815881 100644 --- a/frameworks/projects/spark/src/spark/components/VScrollBar.as +++ b/frameworks/projects/spark/src/spark/components/VScrollBar.as @@ -312,17 +312,20 @@ public class VScrollBar extends ScrollBarBase thumbPosTrackY = trackSize - thumbSize; } - if (!fixedThumbSize) - thumb.setLayoutBoundsSize(NaN, thumbSize); - if (getStyle("autoThumbVisibility") === true) - thumb.visible = thumbSize < trackSize; - - // convert thumb position to parent's coordinates. - thumbPos = track.localToGlobal(new Point(0, thumbPosTrackY)); - if (thumb.parent) - thumbPosParentY = thumb.parent.globalToLocal(thumbPos).y; - - thumb.setLayoutBoundsPosition(thumb.getLayoutBoundsX(), Math.round(thumbPosParentY)); + if (getStyle("autoThumbVisibility") === true) + thumb.visible = thumbSize < trackSize; + + if (thumb.visible) { + if (!fixedThumbSize) + thumb.setLayoutBoundsSize(NaN, thumbSize); + + // convert thumb position to parent's coordinates. + thumbPos = track.localToGlobal(new Point(0, thumbPosTrackY)); + if (thumb.parent) + thumbPosParentY = thumb.parent.globalToLocal(thumbPos).y; + + thumb.setLayoutBoundsPosition(thumb.getLayoutBoundsX(), Math.round(thumbPosParentY)); + } } @@ -508,7 +511,7 @@ public class VScrollBar extends ScrollBarBase { // SDK-28898: reverted previous behavior for desktop, resets // scroll position to zero when all content is removed. - maximum = viewport.contentHeight - viewport.height; + maximum = Math.max(0, viewport.contentHeight - viewport.height); } } }
