jquery window.resizeTo in Slow Motion

蹲街弑〆低调 提交于 2020-01-16 00:55:06

问题


I want to resize a window in slow motion mode but the following code doesn't work and I have no idea what to do:

var myWindow;

function resize() {
   var windowsHeight = jQuery(window).height();
   var windowsWidth = jQuery(window).width();
   var DivX = windowsWidth - 320;
   var DivY = windowsHeight - 480;
}

myWindow = window.open("/", "", "width=320, height=480"); 
myWindow.resizeTo(windowsHeight, windowsWidth),1000;
myWindow.focus();

回答1:


In this example you can see the animation effect. Just customize it as you wish.

The trick is to use a custom animation with jquery.animate.

function pop(){
  var win = window.open("", "Title", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=780, height=200, top=0, left=0");
  win.document.body.innerHTML = "HTML";

  $({foo:0}).animate({foo:100}, {
    step: function(val) {
      win.resizeTo(val * 5, val * 5);
    }
  });
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button onclick="pop()">Open</button>

Note: You can see the effect within the snippet for a security reason. You can see the effect in the fiddle(jsbin) I created:

http://jsbin.com/fojuva

Note 2: I checked this code in Google Chrome and Mozila Firefox The latest versions.



来源:https://stackoverflow.com/questions/28760620/jquery-window-resizeto-in-slow-motion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!