js通过八个点 拖动改变div大小的实现方法_javascript技巧
<script> <BR>var Sys = (function(ua){ <BR> var s = {}; <BR> s.IE = ua.match(/msie ([\d.]+)/)?true:false; <BR> s.Firefox = ua.match(/firefox\/([\d.]+)/)?true:false; <BR> s.Chrome = ua.match(/chrome\/([\d.]+)/)?true:false; <BR> s.IE6 = (s.IE&&([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6))?true:false; <BR> s.IE7 = (s.IE&&([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 7))?true:false; <BR> s.IE8 = (s.IE&&([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 8))?true:false; <BR> return s; <BR>})(navigator.userAgent.toLowerCase()); <P>var $ = function (id) { <BR> return document.getElementById(id); <BR>}; <P>var Css = function(e,o){ <BR> for(var i in o) <BR> e.style[i] = o[i]; <BR>}; <P>var Extend = function(destination, source) { <BR> for (var property in source) { <BR> destination[property] = source[property]; <BR> } <BR>}; <P>var Bind = function(object, fun) { <BR> var args = Array.prototype.slice.call(arguments).slice(2); <BR> return function() { <BR> return fun.apply(object, args); <BR> } <BR>}; <P>var BindAsEventListener = function(object, fun) { <BR> var args = Array.prototype.slice.call(arguments).slice(2); <BR> return function(event) { <BR> return fun.apply(object, [event || window.event].concat(args)); <BR> } <BR>}; <P>var CurrentStyle = function(element){ <BR> return element.currentStyle || document.defaultView.getComputedStyle(element, null); <BR>}; <P>function addListener(element,e,fn){ <BR> element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn); <BR>}; <BR>function removeListener(element,e,fn){ <BR> element.removeEventListener?element.removeEventListener(e,fn,false):element.detachEvent("on" + e,fn) <BR>}; <P>var Class = function(properties){ <BR> var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;}; <BR> _class.prototype = properties; <BR> return _class; <BR>}; <P>var Resize =new Class({ <BR> initialize : function(obj){ <BR> this.obj = obj; <BR> this.resizeelm = null; <BR> this.fun = null; //记录触发什么事件的索引 <BR> this.original = []; //记录开始状态的数组 <BR> this.width = null; <BR> this.height = null; <BR> this.fR = BindAsEventListener(this,this.resize); <BR> this.fS = Bind(this,this.stop); <BR> }, <BR> set : function(elm,direction){ <BR> if(!elm)return; <BR> this.resizeelm = elm; <BR> addListener(this.resizeelm,'mousedown',BindAsEventListener(this, this.start, this[direction])); <BR> return this; <BR> }, <BR> start : function(e,fun){ <BR> this.fun = fun; <BR> this.original = [parseInt(CurrentStyle(this.obj).width),parseInt(CurrentStyle(this.obj).height),parseInt(CurrentStyle(this.obj).left),parseInt(CurrentStyle(this.obj).top)];<BR> this.width = (this.original[2]||0) + this.original[0]; <BR> this.height = (this.original[3]||0) + this.original[1]; <BR> addListener(document,"mousemove",this.fR); <BR> addListener(document,'mouseup',this.fS); <BR> }, <BR> resize : function(e){ <BR> this.fun(e); <BR> Sys.IE?(this.resizeelm.onlosecapture=function(){this.fS()}):(this.resizeelm.onblur=function(){this.fS()}) <BR> }, <BR> stop : function(){ <BR> removeListener(document, "mousemove", this.fR); <BR> removeListener(document, "mousemove", this.fS); <BR> window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); <BR> }, <BR> up : function(e){ <BR> this.height>e.clientY?Css(this.obj,{top:e.clientY + "px",height:this.height-e.clientY + "px"}):this.turnDown(e); <BR> }, <BR> down : function(e){ <BR> e.clientY>this.original[3]?Css(this.obj,{top:this.original[3]+'px',height:e.clientY-this.original[3]+'px'}):this.turnUp(e); <BR> }, <BR> left : function(e){ <BR> e.clientX<this.width?Css(this.obj,{left:e.clientX +'px',width:this.width-e.clientX + "px"}):this.turnRight(e); <BR> }, <BR> right : function(e){ <BR> e.clientX>this.original[2]?Css(this.obj,{left:this.original[2]+'px',width:e.clientX-this.original[2]+"px"}):this.turnLeft(e) ; <BR> }, <BR> leftUp:function(e){ <BR> this.up(e);this.left(e); <BR> }, <BR> leftDown:function(e){ <BR> this.left(e);this.down(e); <BR> }, <BR> rightUp:function(e){ <BR> this.up(e);this.right(e); <BR> }, <BR> rightDown:function(e){ <BR> this.right(e);this.down(e); <BR> }, <BR> turnDown : function(e){ <BR> Css(this.obj,{top:this.height+'px',height:e.clientY - this.height + 'px'}); <BR> }, <BR> turnUp : function(e){ <BR> Css(this.obj,{top : e.clientY +'px',height : this.original[3] - e.clientY +'px'}); <BR> }, <BR> turnRight : function(e){ <BR> Css(this.obj,{left:this.width+'px',width:e.clientX- this.width +'px'}); <BR> }, <BR> turnLeft : function(e){ <BR> Css(this.obj,{left:e.clientX +'px',width:this.original[2]-e.clientX+'px'}); <BR> } <BR>}); <BR>window.onload = function(){ <BR> new Resize($('ss')).set($('rUp'),'up').set($('rDown'),'down').set($('rLeft'),'left').set($('rRight'),'right').set($('rLeftUp'),'leftUp').set($('rLeftDown'),'leftDown').set($('rRightDown'),'rightDown').set($('rRightUp'),'rightUp');<BR>} <BR></script>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

如何使用JS和百度地图实现地图平移功能百度地图是一款广泛使用的地图服务平台,在Web开发中经常用于展示地理信息、定位等功能。本文将介绍如何使用JS和百度地图API实现地图平移功能,并提供具体的代码示例。一、准备工作使用百度地图API前,首先需要在百度地图开放平台(http://lbsyun.baidu.com/)上申请一个开发者账号,并创建一个应用。创建完成

人脸检测识别技术已经是一个比较成熟且应用广泛的技术。而目前最为广泛的互联网应用语言非JS莫属,在Web前端实现人脸检测识别相比后端的人脸识别有优势也有弱势。优势包括减少网络交互、实时识别,大大缩短了用户等待时间,提高了用户体验;弱势是:受到模型大小限制,其中准确率也有限。如何在web端使用js实现人脸检测呢?为了实现Web端人脸识别,需要熟悉相关的编程语言和技术,如JavaScript、HTML、CSS、WebRTC等。同时还需要掌握相关的计算机视觉和人工智能技术。值得注意的是,由于Web端的计

如何使用PHP和JS创建股票蜡烛图股票蜡烛图是股票市场中常见的一种技术分析图形,通过绘制股票的开盘价、收盘价、最高价和最低价等数据,帮助投资者更直观地了解股票的价格波动情况。本文将教你如何使用PHP和JS创建股票蜡烛图,并附上具体的代码示例。一、准备工作在开始之前,我们需要准备以下环境:1.一台运行PHP的服务器2.一个支持HTML5和Canvas的浏览器3

股票分析必备工具:学习PHP和JS绘制蜡烛图的步骤,需要具体代码示例随着互联网和科技的快速发展,股票交易已经成为许多投资者的重要途径之一。而股票分析是投资者决策的重要一环,其中蜡烛图被广泛应用于技术分析中。学习如何使用PHP和JS绘制蜡烛图将为投资者提供更多直观的信息,帮助他们更好地做出决策。蜡烛图是一种以蜡烛形状来展示股票价格的技术图表。它展示了股票价格的

如何使用JS和百度地图实现地图点击事件处理功能概述:在Web开发中,经常需要使用地图功能来展示地理位置和地理信息。而地图上的点击事件处理是地图功能中常用且重要的一部分。本文将介绍如何使用JS和百度地图API来实现地图的点击事件处理功能,并给出具体的代码示例。步骤:导入百度地图的API文件首先,要在HTML文件中导入百度地图API的文件,可以通过以下代码实现:

如何使用JS和百度地图实现地图热力图功能简介:随着互联网和移动设备的迅速发展,地图成为了一种普遍的应用场景。而热力图作为一种可视化的展示方式,能够帮助我们更直观地了解数据的分布情况。本文将介绍如何使用JS和百度地图API来实现地图热力图的功能,并提供具体的代码示例。准备工作:在开始之前,你需要准备以下事项:一个百度开发者账号,并创建一个应用,获取到相应的AP

随着互联网金融的迅速发展,股票投资已经成为了越来越多人的选择。而在股票交易中,蜡烛图是一种常用的技术分析方法,它能够显示股票价格的变化趋势,帮助投资者做出更加精准的决策。本文将通过介绍PHP和JS的开发技巧,带领读者了解如何绘制股票蜡烛图,并提供具体的代码示例。一、了解股票蜡烛图在介绍如何绘制股票蜡烛图之前,我们首先需要了解一下什么是蜡烛图。蜡烛图是由日本人

如何使用JS和百度地图实现地图多边形绘制功能在现代网页开发中,地图应用已经成为常见的功能之一。而地图上绘制多边形,可以帮助我们将特定区域进行标记,方便用户进行查看和分析。本文将介绍如何使用JS和百度地图API实现地图多边形绘制功能,并提供具体的代码示例。首先,我们需要引入百度地图API。可以利用以下代码在HTML文件中导入百度地图API的JavaScript
