Home > Web Front-end > JS Tutorial > In-depth analysis of jQuery's size adjustment component_jquery

In-depth analysis of jQuery's size adjustment component_jquery

WBOY
Release: 2016-05-16 17:31:51
Original
1433 people have browsed it
1: The Resizable component can turn the selected DOM element into a resizable object , that is, its size can be changed by dragging the adjustment handle.
$(".selector").resizeable(options);
Simple example:
Copy Code The code is as follows:





resizable component
< script language="javascript" src="js/jquery-1.4.2.min.js">













Rendering:

In fact, after calling the resizable() method, div elements will be added to the right border, bottom border and lower right corner of the target object, and ui-resizable-e, ui-resizable-s, will be added to the div elements in sequence. ui-resizable-se class, thus forming a drag handle

2: Delay adjustment

Copy code The code is as follows:





resizable组件











 

   

     
延迟调整

      ×

   
拖动最外边框查看效果,参数如下

    时间延迟:500

     距离延迟:20

 






3:动态调整效果
需要借助尺寸调整组件的一下属性来实现:
*为helper属性设置一个CSS样式类,该样式类将在调整过程中显示元素大小的轮廓,操作结束后才调整原始元素的大小
*设置ghost属性为true,在调整过程中显示一个半透明的辅助元素
*将animate属性设置为true,为元素的调整过程添加动画效果
*为animateDuration属性指定一个值,设置动画过程持续的时间
复制代码 代码如下:





resizable组件











 

魔兽争霸


 

来源:知识宝库网 | 浏览次数:431052次 | 创建时间:2010-10-23


 

魔兽争霸是一款非常著名的即时战略游戏。制作公司是美国的暴雪公司。最新版本为“魔兽争霸3:冰封王座”,目前的版本号为1.24.1.6374(更新至2009年8月26号)。


 

目前是单机游戏中非常受欢迎的游戏,除此之外,魔兽争霸还包括了游戏的同名电影。






效果图:
 
4:尺寸调整组件的方法
尺寸调整组件有4个方法,他们都是拖动组件和投放组件所共有的,即disable方法、enable方法、destroy方法和option方法
复制代码 代码如下:

   //禁止调整尺寸功能
  $(".selector").resizable('disable');
  //重新激活对象的可调整尺寸功能
  $(".selector").resizable('enable');
 //移除可调整尺寸功能
 $('.selector').resizable('destroy');
 //在初始化后设置maxHeight属性的值为480
  $('.selector').resizable('option', 'maxHeight', 480);
 //在初始化后获取maxHeight属性的值
  $('.selector').resizable('option', "maxHeight");

5:调整事件回调函数
start:事件类型resizestart, 开始拖动改变大小时触发
resize: 事件类型resize, 拖动过程中,鼠标每移动一像素就触发一次
stop: 事件类型resizestop, 停止拖动时触发
复制代码 代码如下:

  $("#droppable").droppable({
     eventName: function(event, ui) {
        //具体处理代码,this表示可调整尺寸的对象
    }
});

ui is a jQuery object containing additional information. The jQuery object has the following properties:
helper: a jQuery object representing a draggable helper element
originalPosition: an object containing top attributes and left attributes, indicating the position of the element relative to the original object before starting to adjust
originalSize: an object containing width and height attributes, indicating the size of the element before starting to adjust
position : An object containing top attributes and left attributes, indicating the position of the current element relative to the original object
size: An object containing width attributes and height attributes, indicating the size of the current element
Simple example:
Copy code The code is as follows:


















span>×











Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template