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

wind.setPosition('center'); 这个方法不能生效 #4702

Closed
phpjishu opened this issue Apr 11, 2016 · 3 comments
Closed

wind.setPosition('center'); 这个方法不能生效 #4702

phpjishu opened this issue Apr 11, 2016 · 3 comments
Labels

Comments

@phpjishu
Copy link

`

<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <script>
        function test(){
            var wind = nw.Window.get();
            wind.resizeTo(1024, 768);
            wind.setMinimumSize(1024, 768);
            wind.setResizable(true);
            wind.setPosition('center'); //这个方法不能生效
        }
    </script>
</head>

<body style="overflow: hidden;">
<button onclick="test()">调整窗口到1024*768</button>
</body>
`
@Christywl
Copy link
Contributor

Need add timeout for setPosition method. Please see #5390 (comment) and #5390 (comment)

My code works fine:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <script>
        function test(){
            var wind = nw.Window.get();
            wind.resizeTo(1024, 768);
            wind.setMinimumSize(1024, 768);
            wind.setResizable(true);
         //   wind.setPosition('center'); //这个方法不能生效
		setTimeout(() => {	wind.setPosition('center');},1000);
        }
    </script>
</head>

<body style="overflow: hidden;">
<button onclick="test()">调整窗口到1024*768</button>
</body>
</html>

@Christywl
Copy link
Contributor

close until there is more information.

@liangran
Copy link

Below code works fine.

        win.once('loaded', function(){
		win.setPosition("center"); 
	});

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

No branches or pull requests

3 participants