void updateScroll(){ bool vBar = _scrollBar && _scrollBar->isVisible(), vNode = _scrollNode && _scrollNode->isVisible(); if(!vBar || !vNode){ return; } bool vert = getDirection() == kCCScrollViewDirectionVertical; CCPoint p, cp = getContentOffset(); CCSize vs = getViewSize(), cs = getContentSize(); float rate = 1 - (vert? fabsf(cp.y) / (cs.height - vs.height) : fabsf(cp.x) / (cs.width - vs.width)); if(vBar){ CCSize ss = _scrollBar->getPreferredSize(); p = _scrollBar->getPosition(); if(vert){ p.y = cs.height - (cs.height - ss.height) * rate - ss.height - _scrollTrackDelta; }else{ p.x = cs.width - (cs.width - ss.width) * rate - ss.width - _scrollTrackDelta; } _scrollBar->setPosition(p); } if(vNode){ p = _scrollNode->getPosition(); if(vert){ p.y = cp.y + vs.height * rate; }else{ p.x = cp.x + vs.width * rate; } _scrollNode->setPosition(p); } if(_scrollTrack){ p = _scrollTrack->getPosition(); if(vert){ p.y = fabsf(cp.y); }else{ p.x = fabsf(cp.x); } _scrollTrack->setPosition(p); } //CCLog("LuaTableView.updateScroll ss=%d,%d vh=%d cy=%d ch=%d y=%d", (int)ss.width, (int)ss.height, (int)vs.height, (int)p.y, (int)cs.height, (int)_scrollBar->getPositionY()); }