@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (l == getClientWidth() * currentItem) { virtualPos = 0; } }
/** * Called when page is scrolled. Updates virtualPos of page according to scroll position. * * @param xPos xPos * @return true if scrolled */ private boolean pageScrolled(int xPos) { if (items.size() == 0) { return false; } final int deltaScroll = xPos - lastScroll; virtualPos = reversePos ? virtualPos + deltaScroll : virtualPos - deltaScroll; lastScroll = xPos; final int width = getClientWidth(); final float pageOffset = virtualPos / width; if (onCardChangeListener != null) { onCardChangeListener.onCardScrolled(currentItem, pageOffset, (int) virtualPos); } onPageScrolled(); return true; }
final int width = getClientWidth(); final float scrollOffset = width > 0 ? (float) getScrollX() / width : 0; final float marginOffset = 0;
/** * This method will be invoked when the current page is scrolled, either as part * of a programmatically initiated smooth scroll or a user initiated touch scroll. */ protected void onPageScrolled() { final int scrollX = getScrollX(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final float transformPos = (float) (child.getLeft() - scrollX) / getClientWidth(); transformPage(child, transformPos); } }
private void scrollToItem(int item, boolean smoothScroll, int velocity) { final ItemInfo curInfo = infoForPosition(item); int destX = 0; if (curInfo != null) { destX = (int) (getClientWidth() * Math.max(firstOffset, Math.min(curInfo.offset, lastOffset))); } if (smoothScroll) { smoothScrollTo(destX, 0, velocity); } else { completeScroll(false); scrollTo(destX, 0); pageScrolled(destX); } }
final int width = getClientWidth(); final int halfWidth = width / 2; final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
final int width = getClientWidth();
int itemIndex = curIndex - 1; ItemInfo ii = itemIndex >= 0 ? items.get(itemIndex) : null; final int clientWidth = getClientWidth(); final float leftWidthNeeded = clientWidth <= 0 ? 0 : 2.f - curItem.widthFactor + (float) getPaddingLeft() / (float) clientWidth;
unableToDrag = false; double scroll = getScrollX() / getClientWidth();
final int width = getClientWidth(); final int scrollX = getScrollX(); final ItemInfo ii = infoForCurrentScrollPosition();