Jump to content

Scrollbar issue


Recommended Posts

Posted

Well this is weird, every time i click the position where it is is not remembered and jumps to 0...

  
scrollbar = {} 
function scrollBar(_,_,cx,cy) 
if not scrollbar.oldx then 
return 
end 
local bx,by = 582,368 
local mx,my = cx - scrollbar.oldx, cy - scrollbar.oldy 
    if upanel.tab.achivements.scroll.moving1 then 
    local start = by-338 
    local ending = by-166 
    local total = ending-start 
    local oldprog = upanel.tab.achivements.scroll.list1 -- This is a 0-1 progress 
     
    local current = (total * oldprog) 
    outputChatBox(my.." "..my / (total / 338) ) 
    local my = my 
    local current = current + my 
    local prog = current / 338 
    local prog = math.min(prog,1) 
    local prog = math.max(prog,0) 
    --outputChatBox(oldprog.. " "..prog) 
    upanel.tab.achivements.scroll.list1 = prog 
    end 
end 
  
  
addEventHandler('onClientKey',root,function(key,status) 
local bx,by = 582,366 
if key == "mouse1" then 
    if showingPanel then 
        if tab == 1 then 
            if isCursorShowing() then 
            local cx,cy = getCursorPosition() 
            local cx,cy = cx*x,cy*y 
                if status then 
                        outputChatBox(cx.." "..x*0.525+22+bx-12) 
                    if cx > x*0.525+22+bx-12 and cx < x*0.525+22+bx then 
                             
                    local progress = upanel.tab.achivements.scroll.list1 or 0.2 
                    local start = by-338 
                    local ending = by-166 
                    local middle = ending-start 
                    local pos = middle*progress 
                    local by = by-338 + y*0.4+20 + pos 
                        if cy > by and cy < by + 166 then 
                        addEventHandler('onClientCursorMove',root,scrollBar) 
                        upanel.tab.achivements.scroll.moving1 = true 
                        scrollbar.oldx = cx 
                        scrollbar.oldy = cy 
                        end 
                    end 
                else 
                    if upanel.tab.achivements.scroll.moving1 then 
                        removeEventHandler('onClientCursorMove',root,scrollBar) 
                        scrollbar = {} 
                    end 
                end 
            end 
        end 
    end 
end 
end) 
  

I tried doing the follow on the first function:

  
    local prog = current / total 
  

It works.. but the scrollbar kinda bugs on, moves faster than the mouse and not properly.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...