Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I need to center the segement pointer when its stop #50

Closed
mehuljariwala opened this issue Jun 19, 2018 · 1 comment
Closed

I need to center the segement pointer when its stop #50

mehuljariwala opened this issue Jun 19, 2018 · 1 comment

Comments

@mehuljariwala
Copy link

i need to set like this when its stop spining then its wheel come on center like not any different engle

@zarocknz
Copy link
Owner

Hello @mehuljariwala

There is no built in function for that, so the way to do this is to add this function to your html page...

// This function returns the center angle of the specified segment.
function getCenterForSegment(segmentNumber)
{
    var stopAngle = 0;

    if (segmentNumber)
    {
        if (typeof theWheel.segments[segmentNumber] !== 'undefined')
        {
            var startAngle = theWheel.segments[segmentNumber].startAngle;
            var endAngle = theWheel.segments[segmentNumber].endAngle;
            var range = (endAngle - startAngle);

            if (range > 0)
            {
                stopAngle = Math.floor(startAngle + range / 2);
            }
        }
    }
    
    return stopAngle;
}

Then in the code which sets the stopAngle before the spinning starts, instead of calling getRandomForSegment as seen in the tutorial http://dougtesting.net/winwheel/docs/tut14_setting_the_prize call the getCenterForSegment function instead passing in the segment number

// Set the stopping location to the center of a segment by calling the function below.
theWheel.animation.stopAngle = getCenterForSegment(3);

Cheers,
DouG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants