TODO: if parent passed, we shold bind to ON_ENTER and get current_index, so no extra work is required.

 repaint the scrollbar
 Taking the data from parent as late as possible in case parent resized, or
 moved around by a container.
165731
def repaint
      if @parent
        @row = @parent.row+1
        @col = @parent.col + @parent.width - 1
        @length = @parent.height - 2
        @list_length = @parent.row_count 
        @current_index ||= @parent.current_index
        @border_attrib ||= @parent.border_attrib
      end
      raise ArgumentError, "current_index must be provided" unless @current_index
      raise ArgumentError, "list_length must be provided" unless @list_length
      my_win = @form ? @form.window : @target_window
      @graphic = my_win unless @graphic
      return unless @repaint_required

      # 2016-01-14 - replacing 1 with space in mvvline since junk is showing up in some cases.
      space_char = " ".codepoints.first

      # first print a right side vertical line
      #bc = $bottomcolor  # dark blue
      bc = $datacolor
      bordercolor = @border_color || bc
      borderatt = @border_attrib || Ncurses::A_REVERSE
      #$log.debug "SCROLL bordercolor #{bordercolor} , #{borderatt} " if $log.debug? 


      @graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
      #$log.debug " XXX SCROLL #{@row} #{@col} #{@length} "
      @graphic.mvvline(@row+0, @col, space_char, @length-0)
      @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)

      # now calculate and paint the scrollbar
      pht = @length
      listlen = @list_length * 1.0
      @current_index = 0 if @current_index < 0
      @current_index = listlen-1 if @current_index >= listlen
      sclen = (pht/listlen)* @length
      sclen = 1 if sclen < 1 # sometimes 0.7 for large lists 100 items 2011-10-1 
      scloc = (@current_index/listlen)* @length
      scloc = (@length - sclen) if scloc > @length - sclen # don't exceed end
      if @current_index == @list_length - 1
        scloc = @length - sclen + 0 # earlier 1, but removed since sclen min 1 2011-10-1 
      end
      @graphic.attron(Ncurses.COLOR_PAIR(@scroll_pair) | borderatt)
      r = @row + scloc
      c = @col + 0
      #$log.debug " XXX SCROLLBAR #{r} #{c} #{sclen} "
      @graphic.mvvline(r, c, space_char, sclen)
      @graphic.attroff(Ncurses.COLOR_PAIR(@scroll_pair) | borderatt)
      @repaint_required = false
    end
574486
protected void handleScroll(ScrollEvent event) {

        String styleName = getState().getStyleName();
        int scrollBarrier = getState().getScrollBarrier();
        int barrierMargin = getState().getBarrierMargin();
        if ((m_widget != null) && (scrollBarrier > 0) && (styleName != null)) {
            if (m_widget.getElement().getScrollTop() > (scrollBarrier + barrierMargin)) {
                m_widget.addStyleDependentName(styleName);
                m_widget.addStyleName(styleName);
            } else if (m_widget.getElement().getScrollTop() < (scrollBarrier - barrierMargin)) {
                m_widget.removeStyleDependentName(styleName);
                m_widget.removeStyleName(styleName);
            }
        }
    }
906
function () {
                var element = this.getElement();
                // This is to handle if there is a scroll
                element.onselectstart = Aria.returnTrue;
                if (this.overlay) {
                    // remove overlay here
                    this.overlay.$dispose();
                    this.overlay = null;
                }
                if (this.proxy && this.proxy.overlay) {
                    element.style.top = (this._elementInitialPosition.top + this._movableGeometry.y - this._movableInitialGeometry.y)
                            + "px";
                    element.style.left = (this._elementInitialPosition.left + this._movableGeometry.x - this._movableInitialGeometry.x)
                            + "px";
                    this.proxy.$dispose();
                    this.proxy = null;
                }

                this.$raiseEvent("dragend");
            }
364829
function() {
      var self = this;
      self.__scrollLeft = self.el.scrollLeft;
      self.__scrollTop = self.el.scrollTop;
    }
579880
public void show(Component parent) {
    Dimension parentSize = parent.getSize();
    Insets insets = getInsets();

    // reduce the width of the scrollpane by the insets so that the popup
    // is the same width as the combo box.
    parentSize.setSize(parentSize.width - (insets.right + insets.left), 10 * parentSize.height);
    Dimension scrollSize = computePopupBounds(parent, 0, getBounds().height, parentSize.width, parentSize.height).getSize();

    scroller.setMaximumSize(scrollSize);
    scroller.setPreferredSize(scrollSize);
    scroller.setMinimumSize(scrollSize);

    super.show(parent, 0, parent.getHeight());
    tree.requestFocusInWindow();
  }
1261324
def _scroll_contents(self, adj):
        
        if self._adjusting:
            return True

        try:
            pos_x = self.hsb.get_value()
            pos_y = self.vsb.get_value()

            pct_x = pos_x / self.rng_x
            # invert Y pct because of orientation of scrollbar
            pct_y = 1.0 - (pos_y / self.rng_y)

            bd = self.viewer.get_bindings()
            bd.pan_by_pct(self.viewer, pct_x, pct_y, pad=self.pad)

            # This shouldn't be necessary, but seems to be
            self.viewer.redraw(whence=0)

        finally:
            self._scrolling = False

        return True
770965
private boolean updateAnchorFromPendingData(RecyclerView.State state, AnchorInfo anchorInfo) {
        if (state.isPreLayout() || mPendingScrollPosition == NO_POSITION) {
            return false;
        }
        // validate scroll position
        if (mPendingScrollPosition < 0 || mPendingScrollPosition >= state.getItemCount()) {
            mPendingScrollPosition = NO_POSITION;
            mPendingScrollPositionOffset = INVALID_OFFSET;
            if (DEBUG) {
                Log.e(TAG, "ignoring invalid scroll position " + mPendingScrollPosition);
            }
            return false;
        }

        // if child is visible, try to make it a reference child and ensure it is fully visible.
        // if child is not visible, align it depending on its virtual position.
        anchorInfo.mPosition = mPendingScrollPosition;
        if (mPendingSavedState != null && mPendingSavedState.hasValidAnchor()) {
            // Anchor offset depends on how that child was laid out. Here, we update it
            // according to our current view bounds
            anchorInfo.mLayoutFromEnd = mPendingSavedState.mAnchorLayoutFromEnd;
            if (anchorInfo.mLayoutFromEnd) {
                anchorInfo.mCoordinate = mOrientationHelper.getEndAfterPadding() -
                        mPendingSavedState.mAnchorOffset;
            } else {
                anchorInfo.mCoordinate = mOrientationHelper.getStartAfterPadding() +
                        mPendingSavedState.mAnchorOffset;
            }
            return true;
        }

        if (mPendingScrollPositionOffset == INVALID_OFFSET) {
            View child = findViewByPosition(mPendingScrollPosition);
            if (child != null) {
                final int childSize = mOrientationHelper.getDecoratedMeasurement(child);
                if (childSize > mOrientationHelper.getTotalSpace()) {
                    // item does not fit. fix depending on layout direction
                    anchorInfo.assignCoordinateFromPadding();
                    return true;
                }
                final int startGap = mOrientationHelper.getDecoratedStart(child)
                        - mOrientationHelper.getStartAfterPadding();
                if (startGap < 0) {
                    anchorInfo.mCoordinate = mOrientationHelper.getStartAfterPadding();
                    anchorInfo.mLayoutFromEnd = false;
                    return true;
                }
                final int endGap = mOrientationHelper.getEndAfterPadding() -
                        mOrientationHelper.getDecoratedEnd(child);
                if (endGap < 0) {
                    anchorInfo.mCoordinate = mOrientationHelper.getEndAfterPadding();
                    anchorInfo.mLayoutFromEnd = true;
                    return true;
                }
                anchorInfo.mCoordinate = anchorInfo.mLayoutFromEnd
                        ? (mOrientationHelper.getDecoratedEnd(child) + mOrientationHelper
                        .getTotalSpaceChange())
                        : mOrientationHelper.getDecoratedStart(child);
            } else { // item is not visible.
                if (getChildCount() > 0) {
                    // get position of any child, does not matter
                    int pos = getPosition(getChildAt(0));
                    anchorInfo.mLayoutFromEnd = mPendingScrollPosition < pos
                            == mShouldReverseLayout;
                }
                anchorInfo.assignCoordinateFromPadding();
            }
            return true;
        }
        // override layout from end values for consistency
        //Act like not reversed if scrollToPositionWithOffset called
        anchorInfo.mLayoutFromEnd = scrollToPositionWithOffsetCalled?false:mShouldReverseLayout;
        if(scrollToPositionWithOffsetCalled){
            //Act like not reversed if scrollToPositionWithOffset called
            anchorInfo.mLayoutFromEnd = false;
            anchorInfo.mCoordinate = mOrientationHelper.getStartAfterPadding() +
                    mPendingScrollPositionOffset;
            scrollToPositionWithOffsetCalled = false;

        }else if (mShouldReverseLayout) {
            anchorInfo.mCoordinate = mOrientationHelper.getEndAfterPadding() -
                    mPendingScrollPositionOffset;
        } else {
            anchorInfo.mCoordinate = mOrientationHelper.getStartAfterPadding() +
                    mPendingScrollPositionOffset;
        }


        return true;
    }
1092828
def on_enter_row arow
      return nil if @list.nil? || @list.size == 0

      @repaint_footer_required = true

      ## can this be done once and stored, and one instance used since a lot of traversal will be done
      require 'canis/core/include/ractionevent'
      aev = TextActionEvent.new self, :ENTER_ROW, current_value().to_s, @current_index, @curpos
      fire_handler :ENTER_ROW, aev
    end
196299
@Override
    public boolean onScroll(ScrollEvent event) {
        lastMovement = System.currentTimeMillis();
        needsDataRefresh = true;
        return false;
    }
735125
def enterEvent(self, event):
        
        super(XViewPanelItem, self).enterEvent(event)

        # store the hover state and mark for a repaint
        self._hovered = True
        self.update()
1217314
function repositionPanel(panel) {
      var scrollY = DomUtils.getViewPort().y;

      function toggleFixedChildPanels(fixed, deltaY) {
        var parent;

        for (var i = 0; i < visiblePanels.length; i++) {
          if (visiblePanels[i] != panel) {
            parent = visiblePanels[i].parent();

            while (parent && (parent = parent.parent())) {
              if (parent == panel) {
                visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint();
              }
            }
          }
        }
      }

      if (panel.settings.autofix) {
        if (!panel.state.get('fixed')) {
          panel._autoFixY = panel.layoutRect().y;

          if (panel._autoFixY < scrollY) {
            panel.fixed(true).layoutRect({ y: 0 }).repaint();
            toggleFixedChildPanels(true, scrollY - panel._autoFixY);
          }
        } else {
          if (panel._autoFixY > scrollY) {
            panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint();
            toggleFixedChildPanels(false, panel._autoFixY - scrollY);
          }
        }
      }
    }
335741
function handleScrollEnd() {
        scrollingStarted = false;
        ghostScrollStart = null;
        clearTimeout(scrollendTID);
        scope.broadcast('scrollend', buildEventData());
    }
43149
def scroll_to(self, selector, by=By.CSS_SELECTOR,
                  timeout=settings.SMALL_TIMEOUT):
        '''  '''
        if self.demo_mode:
            self.slow_scroll_to(selector, by=by, timeout=timeout)
            return
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        element = self.wait_for_element_visible(
            selector, by=by, timeout=timeout)
        try:
            self.__scroll_to_element(element)
        except (StaleElementReferenceException, ENI_Exception):
            self.wait_for_ready_state_complete()
            time.sleep(0.05)
            element = self.wait_for_element_visible(
                selector, by=by, timeout=timeout)
            self.__scroll_to_element(element)
224561
function() {
		var self = this,
			sparse = this.sparse,
			scrollParent;

		if (!sparse.holder) {
			sparse.holder = $('<' + this.options.sparseTagName + ' />', {
				'class': 'list_view_slider ' + this.options.sparseClassName,
				css: {
					width: '100%',
					height: '10000px',
					position: 'relative',
					display: 'block'
				}
			}).appendTo(this.$el);
		} else {
			sparse.holder.appendTo(this.$el);
		}

		scrollParent = nearestScrollableParent(sparse.holder.get(0));

		sparse.holder.css({
			height: '',
			display: ''
		});

		if (!scrollParent) {
			return sparse.holder;
		}
		scrollParent = $(scrollParent);

		this.setupScrollParent(scrollParent);
		this.updateSparseSizing();

		return sparse.holder;
	}
1040023
def repaint # stackflow
      my_win = @form ? @form.window : @target_window
      @graphic = my_win unless @graphic
      raise " #{@name} NO GRAPHIC set as yet                 STACKFLOW paint " unless @graphic
      # actually at this level we don't have margins set -- not yet.
      @margin_left   ||= 0
      @margin_right  ||= 0
      @margin_top    ||= 0
      @margin_bottom ||= 0
      r  = @row + @row_offset + @margin_top
      c  = @col + @col_offset + @margin_left
      ht = @height-2-(@margin_top + @margin_bottom)
      wd = @width -2-(@margin_left + @margin_right)
      # should this not happen only if repaint_required ?
      @components.each { |e| 
        e.parent_component = self
        e.row              = r
        e.col              = c
        # check that we are not trying to print outside bounds
        # by default we are stacking top level comps regardless of stack or flow
        #  otherwise too complicated
        if e.is_a? BaseStack 
          # using ||= allows us to use overrides given by user
          # but disallows us from calculating if size changes
            e.height           = (ht) * (e.weight * 0.01)
            e.height           = e.height.round 
            e.width            = wd 
            if e.row + e.height >= @row + @height
              #alert "is exceeding #{e.row} #{e.height} > #{@row} + #{@height} "
              e.height = @height - e.row - 1
            end
            r += e.height
            $log.debug "XXX: STACK r:#{e.row} e.h: #{e.height} w:#{e.weight} h: #{@height} "
          #if e.type == :flow
            #e.height           ||= (@height-2) * (e.weight * 0.01)
            #e.height           = e.height.round
            #e.width            ||= (@width-2) 
            #r += e.height
          #elsif e.type == :stack
            #e.width            ||= (@width-2) * (e.weight * 0.01)
            #e.width            = e.width.round
            #e.height           ||= (@height-2)
            #c += e.width
          #end
        end
        check_coords e
        attach_form e unless e.form
      } # seeme one if printing out
      last = @components.last
      if last.row + last.height < @row + @height
        last.height += 1 # @row + @height - last.row + last.height
      end

      # if some major change has happened then repaint everything
      # if multiple components then last row and col needs to be stored or else overlap will happen FIXME
      if @repaint_required
        $log.debug " STACKFLOW repaint graphic #{@graphic}, size:#{@components.size} "
        print_borders unless @suppress_borders # do this once only, unless everything changes
        @components.each { |e| e.repaint_all(true); e.repaint }
      else
        @components.each { |e| e.repaint }
      end # if repaint_required

      @repaint_required = false
    end
1374509
function () {
            var t = this;
            t.$ed.removeClass('autogrow-on-enter');
            var oldHeight = t.$ed[0].clientHeight;
            t.$ed.height('auto');
            var totalHeight = t.$ed[0].scrollHeight;
            t.$ed.addClass('autogrow-on-enter');
            if (oldHeight !== totalHeight) {
                t.$ed.height(oldHeight);
                setTimeout(function () {
                    t.$ed.css({height: totalHeight});
                    t.$c.trigger('tbwresize');
                }, 0);
            }
        }
578864
function() {
				var view = that.view,
					editable = that.editable,
					trigger = that.trigger,
					upper = trigger.upper,
					lower = trigger.lower,
					any = upper || lower,
					parent = any.getParent(),
					styleSet = {};

				// Save recent trigger for further insertion.
				// It is necessary due to the fact, that that.trigger may
				// contain different boxTrigger at the moment of insertion
				// or may be even null.
				this.trigger = trigger;

				upper && updateSize( that, upper, true );
				lower && updateSize( that, lower, true );
				updateSize( that, parent, true );

				// Yeah, that's gonna be useful in inline-mode case.
				if ( that.inInlineMode )
					updateEditableSize( that, true );

				// Set X coordinate (left, right, width).
				if ( parent.equals( editable ) ) {
					styleSet.left = view.scroll.x;
					styleSet.right = -view.scroll.x;
					styleSet.width = '';
				} else {
					styleSet.left = any.size.left - any.size.margin.left + view.scroll.x - ( that.inInlineMode ? view.editable.left + view.editable.border.left : 0 );
					styleSet.width = any.size.outerWidth + any.size.margin.left + any.size.margin.right + view.scroll.x;
					styleSet.right = '';
				}

				// Set Y coordinate (top) for trigger consisting of two elements.
				if ( upper && lower ) {
					// No margins at all or they're equal. Place box right between.
					if ( upper.size.margin.bottom === lower.size.margin.top )
						styleSet.top = 0 | ( upper.size.bottom + upper.size.margin.bottom / 2 );
					else {
						// Upper margin < lower margin. Place at lower margin.
						if ( upper.size.margin.bottom < lower.size.margin.top )
							styleSet.top = upper.size.bottom + upper.size.margin.bottom;
						// Upper margin > lower margin. Place at upper margin - lower margin.
						else
							styleSet.top = upper.size.bottom + upper.size.margin.bottom - lower.size.margin.top;
					}
				}
				// Set Y coordinate (top) for single-edge trigger.
				else if ( !upper )
					styleSet.top = lower.size.top - lower.size.margin.top;
				else if ( !lower )
					styleSet.top = upper.size.bottom + upper.size.margin.bottom;

				// Set box button modes if close to the viewport horizontal edge
				// or look forced by the trigger.
				if ( trigger.is( LOOK_TOP ) || inBetween( styleSet.top, view.scroll.y - 15, view.scroll.y + 5 ) ) {
					styleSet.top = that.inInlineMode ? 0 : view.scroll.y;
					this.look( LOOK_TOP );
				} else if ( trigger.is( LOOK_BOTTOM ) || inBetween( styleSet.top, view.pane.bottom - 5, view.pane.bottom + 15 ) ) {
					styleSet.top = that.inInlineMode ?
							view.editable.height + view.editable.padding.top + view.editable.padding.bottom
						:
							view.pane.bottom - 1;

					this.look( LOOK_BOTTOM );
				} else {
					if ( that.inInlineMode )
						styleSet.top -= view.editable.top + view.editable.border.top;

					this.look( LOOK_NORMAL );
				}

				if ( that.inInlineMode ) {
					// 1px bug here...
					styleSet.top--;

					// Consider the editable to be an element with overflow:scroll
					// and non-zero scrollTop/scrollLeft value.
					// For example: divarea editable. (#9383)
					styleSet.top += view.editable.scroll.top;
					styleSet.left += view.editable.scroll.left;
				}

				// Append `px` prefixes.
				for ( var style in styleSet )
					styleSet[ style ] = CKEDITOR.tools.cssLength( styleSet[ style ] );

				this.setStyles( styleSet );
			}