$(function(){
var isDownChat = false,
chat = $("#chat");
$("#chat-resize").on("mousedown",function(){
isDownChat = true;
// console.log( parseInt($("#chat-resize").offset().left))
});
$(document).on("mouseup",function(){
isDownChat = false;
$(".modalChat").css("display","none");
$("#chat-resize").css("background","");
});
$(document).on("mousemove",function(e){
if(isDownChat) {
$(".modalChat").css("display","block");
$("#chat-resize").css("background","#2196f3");
var curElementLeft = parseInt(chat.offset().left); // 当前 chat元素左边距
var curElementWidth = chat.width(); // chat的宽度
var mouseLeft = e.pageX; // 鼠标的X坐标
var offsetWidth = curElementLeft-mouseLeft; //宽度差值
var w = Math.max("570",(curElementWidth+offsetWidth));
chat.css("width",w+"px");
}
})
})
一只萌萌小番薯
相关分类