Splitter
- <!DOCTYPE html>
- <html>
- <head>
- <title>PDemo</title>
- </head>
- <body>
- <div id="test">
- <div id="container" style="position:absolute; top:0px;height:535px;width:805px;left:0px; background-color:red;">
- <div id="leftPanel" style="position:absolute;top:0px;width:400px;height:535px;left:0px;overflow:hidden;background-color:gray;"></div>
- <div id="splitterBar" onmousedown="fnMouseDown(event,200,600,400,400);" style="padding:0px;border:0px;height:100%; left:400px;top:0;width:5px;background-color:black;cursor:w-resize;position:absolute;border-style:solid;"
- ></div>
- <div id="rightPanel" style="position:absolute; left:405px;top:0;height:535px;width:400px;min-width:200px;max-width:600px;overflow:hidden; background-color:green;"></div>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- function fnMouseDown(ev,minLeftWidth,maxLeftWidth,oriLeftWidth, oriRightWidth){
- var splitterBar = document.getElementById('splitterBar');
- var leftPanel = document.getElementById('leftPanel');
- var rightPanel = document.getElementById('rightPanel');
- var container = document.getElementById('container');
- var minLeftWidths = minLeftWidth;
- var maxLeftWidths = maxLeftWidth;
- var origianlLeftWidth = oriLeftWidth;
- var originalRightWidth = oriRightWidth;
- var left = splitterBar.offsetLeft;
- var oWidth = leftPanel.offsetWidth;
- var rightLeft = rightPanel.offsetLeft;
- var containerWidth = parseInt(container.style.width);
- var leftPanelWidth = parseInt(leftPanel.style.width);
- var rightPanelWidth = parseInt(rightPanel.style.width);
- var splitterBarWidth = parseInt(splitterBar.style.width);
- var oEvent = ev || event;
- var disX = oEvent.clientX - left;
- var disForRightPanel = rightLeft - oEvent.clientX;
- document.onmousemove = function (ev){
- var oEvent = ev || event
- var currentleftWidth = oEvent.clientX - disX;
- if(currentleftWidth > maxLeftWidths || leftPanelWidth > maxLeftWidths){
- leftPanel.style.width = origianlLeftWidth + 200 + "px";
- splitterBar.style.left = origianlLeftWidth + 200 + "px";
- rightPanel.style.width = rightPanelWidth - 200 + "px";
- } else if(currentleftWidth < minLeftWidths || leftPanelWidth < minLeftWidths) {
- leftPanel.style.width = origianlLeftWidth - 200 + "px";
- splitterBar.style.left = origianlLeftWidth - 200 + "px";
- rightPanel.style.width = originalRightWidth + 200 + "px";
- } else {
- splitterBar.style.left = oEvent.clientX - disX + 'px';
- console.log("splitterBar.style.left is : " + splitterBar.style.left);
- leftPanel.style.width = oEvent.clientX - disX + 'px';
- //console.log("leftPanel.style.width: " + oEvent.clientX - disX +'sfsdfsdfsd');
- rightPanel.style.left = oEvent.clientX - disX + splitterBarWidth + 'px';
- /*rightPanel.style.width = (containerWidth - parseInt(rightPanel.style.left)) + 'px';*/
- rightPanel.style.width = (containerWidth - (oEvent.clientX - disX) - splitterBarWidth) +'px';
- console.log("rightPanel width" + (containerWidth - (oEvent.clientX - disX) - splitterBarWidth));
- }
- document.onmouseup = function (){
- document.onmousemove= null;
- document.onmouseup = null;
- };
- return false;
- };
- }
- </script>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <title>PDemo</title>
- </head>
- <body>
- <div id="test">
- <div id="container" style="position:absolute; top:0px;height:535px;width:805px;left:0px; background-color:red;">
- <div id="leftPanel" style="position:absolute;top:0px;width:400px;height:535px;left:0px;overflow:hidden;background-color:gray;"></div>
- <div id="splitterBar" onmousedown="fnMouseDown(event,200,600,400,400);" style="padding:0px;border:0px;height:100%; left:400px;top:0;width:5px;background-color:black;cursor:w-resize;position:absolute;border-style:solid;"
- ></div>
- <div id="rightPanel" style="position:absolute; left:405px;top:0;height:535px;width:400px;min-width:200px;max-width:600px;overflow:hidden; background-color:green;"></div>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- function fnMouseDown(ev,minLeftWidth,maxLeftWidth,oriLeftWidth, oriRightWidth){
- var splitterBar = document.getElementById('splitterBar');
- var leftPanel = document.getElementById('leftPanel');
- var rightPanel = document.getElementById('rightPanel');
- var container = document.getElementById('container');
- var minLeftWidths = minLeftWidth;
- var maxLeftWidths = maxLeftWidth;
- var origianlLeftWidth = oriLeftWidth;
- var originalRightWidth = oriRightWidth;
- var left = splitterBar.offsetLeft;
- var oWidth = leftPanel.offsetWidth;
- var rightLeft = rightPanel.offsetLeft;
- var containerWidth = parseInt(container.style.width);
- var leftPanelWidth = parseInt(leftPanel.style.width);
- var rightPanelWidth = parseInt(rightPanel.style.width);
- var splitterBarWidth = parseInt(splitterBar.style.width);
- var oEvent = ev || event;
- var disX = oEvent.clientX - left;
- var disForRightPanel = rightLeft - oEvent.clientX;
- document.onmousemove = function (ev){
- var oEvent = ev || event
- var currentleftWidth = oEvent.clientX - disX;
- if(currentleftWidth > maxLeftWidths || leftPanelWidth > maxLeftWidths){
- leftPanel.style.width = origianlLeftWidth + 200 + "px";
- splitterBar.style.left = origianlLeftWidth + 200 + "px";
- rightPanel.style.width = rightPanelWidth - 200 + "px";
- } else if(currentleftWidth < minLeftWidths || leftPanelWidth < minLeftWidths) {
- leftPanel.style.width = origianlLeftWidth - 200 + "px";
- splitterBar.style.left = origianlLeftWidth - 200 + "px";
- rightPanel.style.width = originalRightWidth + 200 + "px";
- } else {
- splitterBar.style.left = oEvent.clientX - disX + 'px';
- console.log("splitterBar.style.left is : " + splitterBar.style.left);
- leftPanel.style.width = oEvent.clientX - disX + 'px';
- //console.log("leftPanel.style.width: " + oEvent.clientX - disX +'sfsdfsdfsd');
- rightPanel.style.left = oEvent.clientX - disX + splitterBarWidth + 'px';
- /*rightPanel.style.width = (containerWidth - parseInt(rightPanel.style.left)) + 'px';*/
- rightPanel.style.width = (containerWidth - (oEvent.clientX - disX) - splitterBarWidth) +'px';
- console.log("rightPanel width" + (containerWidth - (oEvent.clientX - disX) - splitterBarWidth));
- }
- document.onmouseup = function (){
- document.onmousemove= null;
- document.onmouseup = null;
- };
- return false;
- };
- }
- </script>
- </html>
- <html>
- <head>
- <title>Splitter Control</title>
- </head>
- <script src="../package/reactjs/react.js"></script>
- <script src="../package/reactjs/JSXTransformer.js"></script>
- <style type="text/css">
- .container {
- width: 605px;
- height: 300px;
- height: 300px;
- margin: 0 auto 0 auto;
- margin-top: 50px;
- border: solid 1mm yellow;
- }
- .left-panel {
- width: 300px;
- height: 300px;
- float: left;
- background: grey;
- }
- .right-panel {
- width: 300px;
- height: 300px;
- float: right;
- background: green;
- }
- </style>
- <body>
- <div id="container" class="container">
- <div id="leftPanel" class="left-panel">Left</div>
- <div id="rightPanel" class="right-panel">Right</div>
- </div>
- <script type="text/jsx">
- var disX = 0;
- var isBegin = false;
- var Splitter = React.createClass({
- getInitialState: function()
- {
- var left = document.getElementById(this.props.leftPanel);
- var right = document.getElementById(this.props.rightPanel);
- left.style.width = "100%";
- right.style.width = "100%";
- right.style.height = "100%";
- return {
- originalLeftWidth: this.props.originalLeftWidth,
- originalLeftHeight: this.props.originalLeftHeight,
- originalSplitterWidth: this.props.originalSplitterWidth,
- originalSplitterHeight: this.props.originalSplitterHeight,
- originalRightWidth: this.props.originalRightWidth,
- originalRightHeight: this.props.originalRightHeight,
- currentLeftWidth: this.props.originalLeftWidth,
- currentSplitterLeft: this.props.originalLeftWidth,
- currentRightWidth: this.props.originalRightWidth,
- currentRightLeft: this.props.originalLeftWidth + this.props.originalSplitterWidth,
- leftPanel: left,
- rightPanel:right,
- currentSplitterBackgroundColor: 'blue'
- };
- },
- onMouseMove: function(ev){
- ev.preventDefault();
- if(isBegin == true)
- {
- var currLeftWidth = ev.clientX - disX;
- if(currLeftWidth > this.props.maxLeftWidth || this.state.currentLeftWidth > this.props.maxLeftWidth)
- {
- var cuRightWidth = this.props.originalRightWidth + this.props.originalLeftWidth - this.props.maxLeftWidth;
- this.setState({
- currentLeftWidth:this.props.maxLeftWidth,
- currentSplitterLeft:this.props.maxLeftWidth,
- currentRightWidth:cuRightWidth,
- currentSplitterBackgroundColor: 'black'
- });
- } else if(currLeftWidth < this.props.minLeftWidth || this.state.currentLeftWidth < this.props.mixLeftWidth) {
- var cuRightWidth = this.props.originalRightWidth + this.props.originalLeftWidth - this.props.minLeftWidth;
- this.setState({
- currentLeftWidth:this.props.minLeftWidth,
- currentSplitterLeft:this.props.minLeftWidth,
- currentRightWidth:cuRightWidth,
- currentSplitterBackgroundColor: 'black'
- });
- } else {
- var cuRightWidth = this.props.originalLeftWidth + this.props.originalRightWidth - currLeftWidth;
- this.setState({
- currentLeftWidth:currLeftWidth,
- currentSplitterLeft:currLeftWidth,
- currentRightWidth:cuRightWidth,
- currentSplitterBackgroundColor: 'black'
- });
- }
- }
- },
- onMouseUp: function(){
- isBegin = false;
- disX = 0;
- this.setState({
- currentSplitterBackgroundColor: 'blue'
- });
- document.body.removeEventListener("mouseup", this.onMouseUp);
- document.body.removeEventListener("mousemove", this.onMouseMove);
- },
- onMouseOver: function(){
- this.setState({
- currentSplitterBackgroundColor: 'black'
- });
- },
- onMouseOut: function(){
- this.setState({
- currentSplitterBackgroundColor: 'blue'
- });
- },
- onMouseDown: function(ev){
- isBegin = true;
- var splitter = React.findDOMNode(this.refs.splitter);
- disX = ev.clientX - splitter.offsetLeft;
- document.body.addEventListener("mouseup", this.onMouseUp);
- document.body.addEventListener("mousemove", this.onMouseMove);
- },
- componentDidMount: function()
- {
- this.left= this.refs.left.getDOMNode();
- this.right = this.refs.right.getDOMNode();
- this.left.appendChild(this.state.leftPanel);
- this.right.appendChild(this.state.rightPanel);
- },
- render: function()
- {
- return(
- <div style={{position:'relative'}}>
- <div id="message-list" ref="left" style={{ float:'left',
- width:this.state.currentLeftWidth,
- height:this.state.originalLeftHeight}}>
- </div>
- <div ref="splitter" className='splitter'
- style={{
- left:this.state.currentSplitterLeft,
- height:this.state.originalSplitterHeight,
- width:this.props.originalSplitterWidth,
- backgroundColor: this.state.currentSplitterBackgroundColor,
- float: 'left'
- }}
- onMouseDown={this.onMouseDown}
- onMouseOver={this.onMouseOver}
- onMouseOut={this.onMouseOut}>
- </div>
- <div ref="right" id="right-panel" style={{float:'left',
- overflow: this.props.overflow,
- width:this.state.currentRightWidth,
- height:this.state.originalRightHeight}}>
- </div>
- </div>
- );
- }
- });
- React.render(
- <Splitter
- originalLeftWidth={300}
- originalLeftHeight={300}
- originalSplitterWidth={5}
- originalSplitterHeight={300}
- originalRightWidth={300}
- originalRightHeight={300}
- minLeftWidth={200}
- maxLeftWidth={400}
- leftPanel={"leftPanel"}
- rightPanel={"rightPanel"}
- overflow ={"auto"} />,
- document.getElementById("container")
- );
- </script>
- </body>
- </html>
- 来自 网易手机号码邮箱 -- 有手机就有网易手机号码邮箱,了解详情>
Splitter的更多相关文章
- Ultra Video Splitter & Converter
1. Video Splitter http://www.aone-soft.com/splitter.htm Ultra Video Splitter 是一款视频分割工具.可将一个巨大的AVI/Di ...
- guava之Joiner 和 Splitter
最近在给客户准备一个Guava的分享,所以会陆续的更新关于Guava更多的细节分享.本文将记录Guava中得字符串处理Joiner(连接)和Splitter(分割)处理. Joiner 首先我们来看看 ...
- guava--Joiner、Splitter、MapJoinner、MapSplitter
Joiner: List<String> stringList = new ArrayList<String>(); stringList.add("aa" ...
- angular的splitter案例学习
angular的splitter案例学习,都有注释了,作为自己的备忘. <!DOCTYPE html> <html ng-app="APP"> <he ...
- Google Guava学习笔记——基础工具类Splitter的使用
另一项经常对字符串的操作就是根据指定的分隔符对字符串进行分隔.我们基本上会使用String.split方法: String testString = "Monday,Tuesday,,Thu ...
- Data Flow ->> CDC Control Task, CDC Source, CDC Splitter
CDC Control Task可以从控制CDC数据同步,比如初始化加载.LSN范围的管理.它可以代替另一种做法,就是通过调用一批CDC函数来完成同样的事情.从SSIS的角度来完成,事情编程简单,和另 ...
- Google Guava的splitter用法
google的guava库是个很不错的工具库,这次来学习其spliiter的用法,它是一个专门用来 分隔字符串的工具类,其中有四种用法,分别来小结 1 基本用法: String str = " ...
- Google的Guava工具类splitter和apache stringutil对比 编辑
一直用的是apache的stringutil工具类,其实google的工具类项目 guava中居然也有字符串的分隔类splitter的,在 http://code.google.com/p/guava ...
- c# splitter控件使用简介
摘自:http://blog.itpub.net/26221264/viewspace-735903 1.先在窗体上放置部分一的控件,这里是TreeView控件,然后把它的 Dock 属性设置为 Le ...
随机推荐
- hdu 3909 数独扩展
思路:做法与9*9的一样.只不过是变量. #include<set> #include<map> #include<cmath> #include<queue ...
- UITabBar实现自定义背景及UITabBarItem自定义图片和字体
UITabBarItem *firstItem = [[UITabBarItem alloc]initWithTitle:]; //设置字体颜色(后面设置字体状态)(UITextAttributeTe ...
- 两种局部刷新UITableView的方法的使用条件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //1.取消选 ...
- # HTML && CSS 学习笔记
https://www.zybuluo.com/denglongku/note/532786 1.Div左右居中 <div>1<div> div{ width:300px; h ...
- JQuery.Gantt(甘特图)开发
一.简介 JQuery.Gantt是一个开源的基于JQuery库的用于实现甘特图效果的可扩展功能的JS组件库. 二.前端页面 2.1 资源引用 首先需要将下载到的源码中的CSS.IMG.JS等资源放入 ...
- ubuntu 删除除了某个文件或文件夹之外的所有文件或者目录
今天需要将网站根目录下的所有文件全部删除但是还需要保留phpmyadmin这个文件夹,本来是可以一个一个删除的,后来想应该会有 一个命令是可以用一个命令删除除了phpmyadmin之外的所有文件和文件 ...
- vs2010工具栏 不显示dx控件
进入命令提示符 跳转到Dev控件安装目录,如目录D:\Program Files (x86)\DevExpress 2010.1\Components\Toolss下, 然后执行命令:ToolboxC ...
- UI4_UIStepper与UIProgressView
// // ViewController.m // UI4_UIStepper与UIProgressView // // Created by zhangxueming on 15/7/7. // C ...
- Js获取标签高度
能力有限:问个问题,标签相对页面高度,是怎么写? 鼠标的横坐标,X轴: event.clientX; 鼠标的竖坐标,Y轴: event.clientY; 网页可见区域宽: document.bo ...
- javascript笔记——前端实现分页和查询
//Modal function Modal(obj){ var that = this; that.ref = ""; that.obj = obj; that.init(); ...