jquery-ui中resizable事件的 stop:function(e,ui){} 的ui.originalSize只是content的width和height

1. 结论:

  • jquery-ui中,resizable() 事件的 stop:function(e,ui){....}中, ui.originalSize的属性值height、width,对应的盒模型,只是content的height、width。不包含内边距和边框!!!

    • box-sizing: content-box
      • originalSize{ height:_, width_ }是只有content,不包含内边距、边框
      • size{ height:_, width_ }是只有content,不包含内边距、边框
    • box-sizing: border-box
      • originalSize{ height:_, width_ }是只有content,不包含内边距、边框
      • size{ height:_, width_ }是包含content、内边距、边框的

2. 下面进行验证

将进行给 .resizable-test 元素添加 resizable() 事件

<head>
	<!--引入jquery-ui的css-->
	<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
	    <!--引入 jquery库(必须写在jquery-ui库之前)-->
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <!--引入 jquery-ui 库-->
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
</head>
<body>
    <div id="resizableDiv"></div>
     
    <script>
    	// jquery入口
        $(function () {
        	// 给 resizable-test 元素添加 resizable 事件
            $("#resizableDiv").resizable({
                stop: function(e,ui) {
                    console.log(ui);
                },
            });
        });
    </script>
</body>

3. 对比不同box-sizing下的情况

3.1 box-sizing: content-box;

#resizableDiv {
	box-sizing: content-box;
    width: 300px;
    height: 200px;
    border: 1px solid;
    background-color: pink;
}

(1)拖拽前

在这里插入图片描述

(2)拖拽后

在这里插入图片描述

(3)控制台打印的resizable事件中stop事件的对象ui

  • 对象属性的具体含义可参考菜鸟教程 [https://www.runoob.com/jqueryui/api-resizable.html#event-stop]
    在这里插入图片描述

3.2 box-sizing:border-box;

#resizableDiv {
	box-sizing: border-box;
    width: 300px;
    height: 200px;
    border: 1px solid;
    background-color: pink;
}

(1)拖拽前

在这里插入图片描述

(2)拖拽后

在这里插入图片描述

(3)控制台打印的resizable事件中stop事件的对象ui

  • 对象属性的具体含义可参考菜鸟教程 [https://www.runoob.com/jqueryui/api-resizable.html#event-stop]
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值