jq弹窗拖动改变宽高

news/2024/7/11 1:34:56 标签: css, css3, 前端, jquery, js

预览效果

在这里插入图片描述

<div class='tishiMask'>
	<div class="tishiEm">
		<div id="coor"></div>
		<div class="topNew ismove">
			<span class="ismove">提示</span>
			<p onclick="closeTishi()">×</p>
		</div>
		<div class="bottomNew">
			<p>提示文字软件</p>
			<div class="newDesignBtn">
				<input type="button" value="确定" class="btnLeft" onclick="closeTishi()" >
				<input type="button" value="取消" onclick="closeTishi(this)" class="btnRight">
			</div>
		</div>
	</div>
</div>
.tishiMask{
	width: 100%;
	height: 100%;
	position: fixed;
	top: 0;
	left: 0;
	background-color: rgba(0, 0, 0, .18);
	display: block;
	z-index: 99999;
}
.tishiEm {
	z-index: 99999;
	/* display: none; */
	/* -webkit-transition: -webkit-box-shadow .2s; */
	/* transition: box-shadow .2s; */
	position: fixed;
	height: 220px;
	width: 300px;
	top: 38%;
	/* margin-top: -100px; */
	left: 43%;
	/* margin-left: -150px; */
	background: #fff;
	border-radius: 5px 5px 0px 0px;
	-webkit-box-shadow: 0px 0px 10px 5px rgba(0, 0, 0, 0.4);
	box-shadow: 0px 0px 10px 5px rgba(0, 0, 0, 0.4);
	/* -webkit-transition: -webkit-box-shadow .2s; */
	/* transition: box-shadow .2s; */
	/* transition: all .4s; */
	/* -webkit-transition: all .4s; */
	/* -moz-transition: all .4s; */
}

.tishiEm .topNew {
	overflow: hidden;
	background-image: linear-gradient(183deg, #3d95ea 0%, #70b0e6 100%);
	border-radius: 5px 5px 0px 0px;
}

.tishiEm .topNew span {
	color: #fff;
	font-size: 12px;
	height: 34px;
	line-height: 34px;
	display: block;
	float: left;
	margin-left: 10px;
}

.tishiEm .topNew p {
	float: right;
	color: #fff;
	font-size: 20px;
	height: 34px;
	line-height: 34px;
	display: block;
	margin-right: 10px;
	cursor: pointer;
}

.tishiEm .bottomNew {
	margin: 0px 0px;
}

.tishiEm .bottomNew {
	text-align: center;
}

.tishiEm .bottomNew p {
	font-size: 12px;
	height: 20px;
	line-height: 20px;
}
.tishiEm .bottomNew .newDesignBtn {
	overflow: hidden;
	width: 100%;
	height: auto;
	display: flex;
	justify-content: flex-end;
	align-items: center;
	position: absolute;
	bottom: 10px;
	left: 0;
}

.tishiEm .bottomNew .newDesignBtn .btnLeft {
	display: block;
	float: left;
	box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.22);
	background: #5da2e5;
	color: #fff;
	font-size: 12px;
	width: auto;
	text-align: center;
	height: 24px;
	line-height: 24px;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	padding: 0px 14px;
	border: 1px solid #5da2e5;
}

.tishiEm .bottomNew .newDesignBtn .btnLeft:hover {
	background: #1a78d9;
	border: 1px solid #0069b8;
	color: #fff;
}

.tishiEm .bottomNew .newDesignBtn .btnRight {
	display: block;
	float: left;
	box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.22);
	background: #dcdcdc;
	color: #383838;
	font-size: 12px;
	width: auto;
	text-align: center;
	height: 24px;
	line-height: 24px;
	border-radius: 4px;
	margin-right: 28px;
	margin-left: 10px;
	border: none;
	cursor: pointer;
	padding: 0px 14px;
	border: 1px solid #dcdcdc;
}

.tishiEm .bottomNew .newDesignBtn .btnRight:hover {
	background: #c4c4c4;
	color: #383838;
	border: 1px solid #aaa;
}
#coor, #coor_set, #coor_syt {
	width: 20px;
	height: 20px;
	overflow: hidden;
	cursor: se-resize;
	position: absolute;
	right: 0;
	bottom: 0;
	/* background-color: #09c; */
	background: url(./../images/scale.png);
	background-size: 100% 100%;
	transform: rotate(270deg);
	z-index: 999;
}

类名tishiEm设置宽高为缩小最小宽高。

注意下方js注释

$(function () {
    $(document).mousemove(function (e) {

        if (!!this.move_gy) {

            var posix_gy = !document.move_target_gy ? { 'x': 0, 'y': 0 } : document.move_target_gy.posix_gy,
                callback_gy = document.call_down_gy || function () {
                    let viewWidth = $(document).width();
                    let maxLeft = viewWidth - $(".tishiEm").width();   // 左侧最大移动量

                    let viewHeight = $(document).height();
                    let maxHeight = viewHeight - $(".tishiEm").height();   // 底部最大移动量

                    let currentTop = e.pageY - posix_gy.y;
                    let currentLeft = e.pageX - posix_gy.x;

                    if (currentTop <= 0 || currentLeft <= 0 || currentLeft >= maxLeft || currentTop >= maxHeight) {
                        return
                    } else {
                        $(this.move_target_gy).offset({
                            'top': currentTop,
                            'left': currentLeft
                        });
                    }
                };

            callback_gy.call(this, e, posix_gy);
        }


    }).mouseup(function (e) {
        if (!!this.move_gy) {
            var callback_gy = document.call_up_gy || function () {
            };
            callback_gy.call(this, e);
            $.extend(this, {
                'move_gy': false,
                'move_target_gy': null,
                'call_down_gy': false,
                'call_up_gy': false
            });
        }
    });
    var $box = $('.tishiEm').mousedown(function (e) {
        let offset = $(this).offset();


        this.posix_gy = { 'x': e.pageX - offset.left, 'y': e.pageY - offset.top };
        if (!$(e.target).hasClass('ismove')) {      // 只允许蓝色区域可拖动
            return;
        } else {
            $.extend(document, { 'move_gy': true, 'move_target_gy': this });
        }


    }).on('mousedown', '#coor', function (e) {
        var posix_gy = {
            'w': $box.width(),
            'h': $box.height(),
            'x': e.pageX,
            'y': e.pageY
        };

        $.extend(document, {
            'move_gy': true, 'call_down_gy': function (e) {
            	//下方为最小宽高  同步上方css
                $box.css({
                    'width': Math.max(300, e.pageX - posix_gy.x + posix_gy.w),
                    'height': Math.max(220, e.pageY - posix_gy.y + posix_gy.h)
                });
            }
        });
        return false;
    });
});

http://www.niftyadmin.cn/n/5026010.html

相关文章

2024年山东高企申报注意事项

1、分析企业技术及财务报表 分析财务数据及企业主营产品和技术点。用以确定申报材料的撰写方向。一般耗时1周左右。&#xff08;纺织厂、服装厂等传统行业面临申报中的面临研发人员比例不达标&#xff0c;研发费用不达标&#xff0c;高新技术产品比例不达标等难题。&#xff09…

分享!JetBrains IDE中的GitLab支持

GitLab是流行的基于git的软件开发和部署平台之一&#xff0c;虽然很长一段时间以来&#xff0c;所有基本git操作都已经可以通过GitLab实现&#xff0c;但GitLab集成仍是JetBrains社区的一大最热门请求。为此&#xff0c;JetBrains团队今年与GitLab联手提供了这种类型的集成。 …

Pinctrl子系统_02_使用Pinctrl要掌握的重要概念

本节说明使用Pinctrl子系统时&#xff0c;要掌握的重要概念。 上节我们说到&#xff0c;我们通过Pinctrl子系统来控制设备的引脚&#xff0c;但实际上&#xff0c;大多数芯片都没有一个单独的Pinctrl。引脚的复用、配置等操作&#xff0c;实际上是在GPIO子系统内部实现的。 但…

生产消费者模型的介绍以及其的模拟实现

目录 生产者消费者模型的概念 生产者消费者模型的特点 基于阻塞队列BlockingQueue的生产者消费者模型 对基于阻塞队列BlockingQueue的生产者消费者模型的模拟实现 ConProd.c文件的整体代码 BlockQueue.h文件的整体代码 对【基于阻塞队列BlockingQueue的生产者消费者模型…

《PostgreSQL物化视图:创建、维护与应用》

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f405;&#x1f43e;猫头虎建议程序员必备技术栈一览表&#x1f4d6;&#xff1a; &#x1f6e0;️ 全栈技术 Full Stack: &#x1f4da…

K8S------kube-apiserver Webhook令牌 客户端认证

一、简介 Webhook 身份认证是一种用来验证持有者令牌的回调机制。持有者令牌请看我的另一篇blog,webhook回调详解看我的另一篇blog 二、使用详解 k8s系统要开启webhook令牌验证,需要在kube-apiserver启动的时候启用如下参数: –authentication-token-webhook-config-file…

合宙Air724UG LuatOS-Air LVGL API控件-表格(Table)

表格&#xff08;Table&#xff09; 示例代码 --创建表格Table1 lvgl.table_create(lvgl.scr_act(),nil)--设置表格为4行5列lvgl.table_set_row_cnt(Table1,4)lvgl.table_set_col_cnt(Table1,5)--给每个单元格赋值lvgl.table_set_cell_value(Table1, 0, 0, "选手")l…

iPhone苹果15手机怎么看是国行还是美版或港版的苹果iPhone15手机?

iPhone苹果手机15机型区域版本识别代码 CH代码为国行 LL代码为美版 ZP代码为港版 iPhone苹果15手机怎么看是国行还是美版或港版的苹果iPhone15手机&#xff1f; 1、打开苹果iPhone15手机桌面上的「设置」&#xff1b; 2、在iPhone苹果15手机设置内找到「通用」并点击打开&…