void CScrollView::relocateContainer() { Vec2 tOffset = getContentOffset(); if( validateOffset(tOffset) ) { setContentOffsetEaseInWithoutCheck(tOffset, CSCORLLVIEW_RELOCATE_DURATION, CSCROLLVIEW_MOVE_EASEIN_RATE); } }
void CScrollView::setContentOffsetEaseIn(Vec2 tOffset, float fDuration, float fRate) { if( !m_bBounceable ) { validateOffset(tOffset); } setContentOffsetEaseInWithoutCheck(tOffset, fDuration, fRate); }
void CScrollView::setContentOffsetInDuration(Point tOffset, float fDuration) { if( !m_bBounceable ) { validateOffset(tOffset); } setContentOffsetInDurationWithoutCheck(tOffset, fDuration); }
void CScrollView::performedDeaccelerateScrolling(float dt) { if( m_bDragging ) { stoppedDeaccelerateScroll(); return; } Vec2 tOldOffset; Vec2 tNewOffset; float fDistance = m_fDragSpeed * dt; switch( m_eDirection ) { case eScrollViewDirectionHorizontal: fDistance = m_tScrollDistance.x < 0 ? -fDistance : fDistance; tNewOffset = getContentOffset() + Vec2(fDistance, 0); break; default: fDistance = m_tScrollDistance.y < 0 ? -fDistance : fDistance; tNewOffset = getContentOffset() + Vec2(0, fDistance); break; } tOldOffset = tNewOffset; bool bOutOfView = validateOffset(tNewOffset); if( bOutOfView && !m_bBounceable ) { setContentOffsetWithoutCheck(tNewOffset); stoppedDeaccelerateScroll(); return; } setContentOffsetWithoutCheck(tOldOffset); if( bOutOfView ) { m_fDragSpeed = MIN(CSCROLLVIEW_DEACCELERATE_MAX, m_fDragSpeed); m_fDragSpeed = m_fDragSpeed - CSCROLLVIEW_DEACCELERATE_VA * dt; } else { m_fDragSpeed = CSCROLLVIEW_DEACCELERATE_PERCENTAGE * m_fDragSpeed - CSCROLLVIEW_DEACCELERATE_VA * dt; } if( m_fDragSpeed <= 0 ) { stoppedDeaccelerateScroll(); if( bOutOfView ) { relocateContainerWithoutCheck(tNewOffset); } else { onDeaccelerateScrollEnded(); } } }
void CScrollView::setContentOffset(CCPoint tOffset) { if( !m_bBounceable ) { validateOffset(tOffset); } m_pContainer->setPosition(tOffset); this->onScrolling(); this->executeScrollingHandler(this); }
void CScrollView::setContentOffset(Vec2 tOffset) { if( !m_bBounceable ) { validateOffset(tOffset); } m_pContainer->stopActionByTag(CSCROLLVIEW_MOVE_ACTION_TAG); m_pContainer->setPosition(tOffset); this->onScrolling(); this->executeScrollingHandler(this); }
Structure* Structure::addPropertyTransitionToExistingStructure(Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, PropertyOffset& offset) { ASSERT(!structure->isDictionary()); ASSERT(structure->isObject()); if (Structure* existingTransition = structure->m_transitionTable.get(propertyName.uid(), attributes)) { JSCell* specificValueInPrevious = existingTransition->m_specificValueInPrevious.get(); if (specificValueInPrevious && specificValueInPrevious != specificValue) return 0; validateOffset(existingTransition->m_offset, structure->m_typeInfo.type()); offset = existingTransition->m_offset; return existingTransition; } return 0; }
void CScrollView::onTouchEnded(Touch *pTouch, float fDuration) { if( m_pSelectedWidget && !m_bTouchMoved && !m_pSelectedWidget->isTouchInterrupted() ) { m_pSelectedWidget->executeTouchEndedHandler(pTouch, fDuration); m_bTouchMoved = false; m_bDragging = false; return; } if( m_bDragable ) { if( m_bDeaccelerateable && m_eDirection != eScrollViewDirectionBoth && fDuration < CSCROLLVIEW_DEACCELERATE_INTERVAL ) { Vec2 tEndPoint = convertToNodeSpace(pTouch->getLocation()); switch( m_eDirection ) { case eScrollViewDirectionHorizontal: m_fDragSpeed = abs( m_tTouchBeganPoint.x - tEndPoint.x ) / fDuration; break; default: m_fDragSpeed = abs( m_tTouchBeganPoint.y - tEndPoint.y ) / fDuration; break; } perpareDeaccelerateScroll(); } else { Vec2 tOffset = getContentOffset(); if( validateOffset(tOffset) ) { relocateContainerWithoutCheck(tOffset); } else { onDraggingScrollEnded(); } } } m_bTouchMoved = false; m_bDragging = false; }