- 浏览: 25386 次
- 性别:
- 来自: 北京
最新评论
-
梧栖凤:
得把未经处理的脚本分享出来啊!
跨浏览器可8方向拖拽剪裁框 -
percy30856:
好东西 正在弄这个玩意儿 参考学习了
Animate Baseclass -
percy30856:
菲哥 你的头像,应该换成未满18岁禁止查看
很棒的时间线控件 -
stoneskin:
:哭笑写javascript的也是猿。。。。我们很多猿都是从写 ...
核心只要两行即可实现添加或移除className -
jamesmos:
enix2212 写道tiannet 写道enix2212 写 ...
核心只要两行即可实现添加或移除className
开发版,水平方向已完成,垂直方向没测,可以跨浏览,滚动多个当前元素索引有问题
一年前实现的scroll类
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> * { padding:0; margin:0;} #scroll { width: 212px; overflow: hidden; margin-left: 100px; } #container { height: 100px; overflow: hidden; } #container div { width: 99px; height: 98px; float: left; margin-right: 10px; border: 1px solid #eee; overflow: hidden; } </style> </head> <body> <b id="play">play</b><b id="pause">pause</b> <div id="scroll"> <div id="container"> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div><div>8</div><div>9</div> </div> </div> <script type="text/javascript"> function ScrollClass(O){ if(!(this instanceof arguments.callee)) return new arguments.callee(O); var doc,indicator,that,config,container,scroll,toolkit,items,length,correct; (doc=document,indicator=arguments.callee,that=this,container=scroll=items=correct=null,config={ S:that.S=O.S,//滚动包装 C:that.C=O.C,//滚动容器 D:that.D=O.D,//滚动距离 后面会智能赋值 O:that.O=O.O || 'left',//滚动方式 N:that.N=O.N || 1,//滚动元素的个数 delay:that.delay=O.delay || 2000, //间隔时间 speed:that.speed=O.speed || 1000, auto:that.auto=O.auto || 'true' }); 'function'===typeof(O.callback) && (that.callback=O.callback); var toolkit={ isEmptyO : function (O){ for(var i in O){ return true; }; return false; }, currentStyle : function (element,property){ var computedStyle=null; return undefined!==element.currentStyle ? element.currentStyle[property] : document.defaultView.getComputedStyle(element,null)[property]; }, each:function(object,callback){ var index,i=0,len=object.length,isO=len===undefined || ({}).toString.call(object).slice(8,-1)==='Object'; if (isO) { for (index in object) { if (callback.call(object[index], index, object[index]) === false) { break; } } } else { for (; i < len;) { if (callback.call(object[i], i, object[i++]) === false) { break; } } } } }; var boolean=!! function(){ that.S=scroll=doc.getElementById(config.S),that.C=container=doc.getElementById(config.C),items=container.children,length=items.length; var item=items.item(0),itemSize=0; if(!doc.getElementById(O.S) || !doc.getElementById(O.C) || (config.O==='left' ? container.scrollWidth*2<container.offsetWidth : container.scrollHeight*2<container.offsetHeight)) return false; correct=config.O==='left' ? ( [parseInt(toolkit.currentStyle(item,'marginLeft')),parseInt(toolkit.currentStyle(item,'marginRight'))] ): ( [parseInt(toolkit.currentStyle(item,'marginTop')),parseInt(toolkit.currentStyle(item,'marginBottom'))] ); itemSize=(config.O==='left' ? item.offsetWidth : item.offsetHeight)+(correct[0]>0?correct[0] : correct[1]); // !config.D && (that.D=config.D=(itemSize*config.N)); // config.O==='left' && (container.style.width=(config.D)*length+'px'); container.style.height=container.scrollHeight+'px'; if(config.D%itemSize!==0){ throw new Error('滚动的距离和元素的尺寸不符'); return false; }; config.O=config.O==='left'? 'scrollLeft' : 'scrollTop'; //config.items=Array.prototype.slice.call(items); //that.items=([]).slice.call(items); config.items=[],that.items=[] /*toolkit.each(items,function(a,b){ config.items.push(b); that.items.push(b); })*/ for(var i=0;i<items.length;i++){ var node=items[i] config.items.push(node); that.items.push(node); } !that.scrolling && (that.scrolling=false); return true; }(); if(boolean===false) return false; indicator.fn=indicator.prototype,indicator.fn.constructor=indicator; !this.Tween && (indicator.fn.Tween=function(){ return that.Linear.apply(that,arguments); }); indicator.fn.Linear=function(t,b,c,d){ return c*t/d + b; }; indicator.prototype.fx=function(t,b,c,d){ return Math.ceil(that.Tween.apply(that,arguments)); }; indicator.fn.index=function(node,items){ var index=-1; toolkit.each(items,function(a,b){ if(node===b){ index=a; }; }); return index; }; indicator.fn.compute=function(O){ var t=0,b=0,c=that.D,d=50,timeout,end; !that.stack && (that.stack=[0]); void function(){ var result=that.fx(t,b,c,d); result<=that.D && (t++,that.stack.push(result),timeout=setTimeout(arguments.callee,13)); return false; }(); }; indicator.fn.condition=function(){ var indicator=arguments.callee; if(that.O==='left'){ return indicator=function(){ return that.S.scrollLeft<that.D; }.apply(that); }else{ return indicator=function(){ return that.S.scrollTop<that.D; }.apply(that); }; }; indicator.fn.action=function(){ var k=0,len=that.stack.length,interval,fn=0,distance=0; that.scrolling=true; (k<=len) && ( interval=setInterval(function(){ distance=that.stack[++k], (undefined !==distance && distance<that.D)?( (that.callback && fn===0) &&(fn=1,that.callback.call(that)), that.S.scrollLeft=distance ) : ( distance===that.D && ( fn=0, k=0, clearInterval(interval), that.nodeControl(), setTimeout(function(){that.end();},that.delay) ) ); },13) ); return false; }; indicator.fn.nodeControl=function(){ toolkit.each(new Array(that.N),function(a,b){ var temp=that.items.shift(); a<that.N && ( that.current=that.index(temp,config.items), that.C.appendChild(temp), that.items.push(temp) ); }); // that.S.scrollLeft=0; // }; indicator.fn.end=function(){ that.scrolling=false; }; indicator.fn.activity=function(){ that.loop=setInterval(function(){ (that.scrolling===false && that.S.scrollLeft===0) && ( that.action() ); },5); }; indicator.fn.pause=function (){ clearInterval(that.loop); }; indicator.fn.play=function (){ that.activity(); }; that.compute.call(that,that.O); that.auto==='true' && that.activity(); }; void function(){ var sroll=ScrollClass({S:'scroll',C:'container',speed:2000,delay:2000,N:2,auto:'true',callback:function(){ //console.dir(this); }}); document.getElementById('play').onclick=function(){ sroll.play(); }; document.getElementById('pause').onclick=function(){ sroll.pause(); }; }(); </script> </body> </html>
一年前实现的scroll类
function SlideClass(A) { this.index = 0; this.timer = null; this.parent = A.parent || {}; this.distance = A.distance || 0; this.delay = A.delay || 2000; this.autoPlay = A.autoPlay || "true"; this.counter = A.counter || "false"; this.direction = A.direction || "left"; this.chlid = A.child || "li"; if (!document.getElementById(A.parent)) { throw new Error("包裹的父节点必须") } this.parent = document.getElementById(A.parent); if (this.counter) { this.page = document.getElementById(this.counter) } this.parent.scrollTop = 0; this.parent.scrollLeft = 0; this.sub = this.parent.getElementsByTagName(this.chlid) || {}; this.number = this.sub.length; this.init.call(this) } SlideClass.prototype = { init: function () { if (this.autoPlay === "true") { this.auto.call(this) } if (this.page) { this.pageShow.call(this) } this.fnCall() }, auto: function () { var A = this; this.stop.call(this); this.timer = setInterval(function () { A.next() }, this.delay) }, prev: function () { this.play(-1) }, next: function () { this.play(1) }, fnCall: function () {}, stop: function () { clearInterval(this.timer) }, pageShow: function () { var A = this.index + 1 > this.number ? this.number : this.index + 1; this.page.innerHTML = A + "/" + this.number }, play: function (A) { this.index += A; if (this.index == this.number) { this.index = 0 } if (this.index < 0) { this.index = this.number - 1 } this.fx(this.parent, this.index * this.distance) }, fx: function (D, C) { var A = function (F, E) { var G = Math[F - E > 0 ? "floor" : "ceil"]; return function () { return [F += G((E - F) * 0.01), F - E] } }; var B; if (this.direction === "top") { B = A(D.scrollTop, C); clearInterval(D.timer); D.timer = setInterval(function () { var E = B(); D.scrollTop = E[0]; if (E[1] == 0) { clearInterval(D.timer) } }, 10) } else { B = A(D.scrollLeft, C); clearInterval(D.timer); D.timer = setInterval(function () { var E = B(); D.scrollLeft = E[0]; if (E[1] == 0) { clearInterval(D.timer) } }, 10) } if (this.page) { this.pageShow.call(this) } this.fnCall.call(this) } }; var slide = new SlideClass({ parent: 'preview', child: 'li', distance: 470, delay: 4000, current: 'curr' });
- scroll-dev.zip (2.6 KB)
- 下载次数: 13
发表评论
-
[javascript]9宫格拖拽拼图游戏 puzzle
2012-04-29 09:51 16431.跨浏览器,主流浏览器都可以运行2.纯javascript开 ... -
避免悲剧 密码生成器
2011-12-22 15:35 786最近被暴库的很多,密码安全成为重大问题!如何避免简单密码呢?还 ... -
jQuery创建实例与原型继承揭秘
2011-12-20 23:57 812在普通情况下 ... -
[Javascript]单例模式(singleton )
2011-12-16 15:23 1358Javascript中大家都很习惯用new运算符创建实例。现在 ... -
javascript1.7新语法
2011-12-13 18:30 9221.yield 关键字 Yield的作用与return 差不多 ... -
javascript undo redo
2011-12-09 10:55 2422在浏览器中用调试工具看调用结果 <!DOCTYPE ... -
duffsDevice 高速版
2011-11-25 17:21 838function duffsDevice(items, f ... -
ECMAScript.js2
2011-11-07 11:18 1386package { public native functio ... -
仅限正整数输入
2011-10-27 15:35 914修正了拖拽文本进输入框问题 2011.11.14 &l ... -
Another JavaScript quiz
2011-08-19 18:34 688测试题来自《Another JavaScript quiz》P ... -
跨浏览器可8方向拖拽剪裁框
2011-08-15 20:01 980<!DOCTYPE html PUBLIC &quo ... -
选项卡
2011-08-12 17:36 935<!DOCTYPE html PUBLIC &quo ... -
拖拽排序列表单例
2011-07-27 11:17 1213<!DOCTYPE html PUBLIC &quo ... -
Animate Baseclass
2011-07-12 15:47 1243以下代码仅供参考,请下载附件代码,应该是文本编辑器过滤掉了某些 ... -
很棒的时间线控件
2011-06-24 18:52 1766原生态javascript,希望大家能喜欢 functio ... -
fade方法
2011-05-27 10:12 815function fadeOut(steps){ ... -
核心只要两行即可实现添加或移除className
2011-04-29 11:10 1816<div id="abc" cl ... -
让函数有记忆能力
2011-04-28 15:34 737function addEvent(elem,evType ... -
可以跳动的手风琴 Accordion
2011-04-13 15:02 847<!DOCTYPE html PUBLIC &q ... -
javascript new 关键字的运行原理
2011-04-06 17:33 1580function javascriptNew(t){ a= ...
相关推荐
Mac 路径为 Contents/gradle/m2repository/net/sf/proguard/proguard-base Win gradle/m2repository/net/sf/proguard/proguard-base 为了安全 先备份原来的 jar 将gradle里面的 release { minifyEnabled ...
首先,确保`Scroll`事件被正确地绑定,然后在事件处理函数中设置`SelectedIndex`为最大值,即`ListBox.Items.Count - 1`。这将使ListBox选中最底部的项,从而将滚动条移动到底部。示例代码如下: ```csharp private...
div显示上下滚动条的css代码 ;height:120px; overflow-y:scroll; border:1px solid;"> 这里是你要显示的内容 ... scrollbar-base-color:#ff6600; border:1px solid;"> 这里是你要显示的内容 </div>
* `scroll-bar-base-color`:设置滚动条的主要颜色。 总结 本篇文章详细介绍了 DIV 滚动条的样式设置,包括如何实现 DIV 滚动条、DIV 滚动条的样式设置和滚动条颜色属性。通过设置 `overflow` 属性和滚动条颜色...
ScrollEventArgs se = new ScrollEventArgs(ScrollEventType.EndScroll, _scrollPosition, VerticalScroll.Visible, VerticalScroll.LargeChange, VerticalScroll.SmallChange); OnScroll(se); } // 临时禁用...
base.options = $.extend({}, $.ScrollFixed.defaultOptions, options); $(window).resize(windowResize); $(window).scroll(windowScroll); _fix_position(); console.log(base.options.fixed); }; base....
为了实现滚动条的动态变化,例如滑块的移动,还需要处理Scroll事件。在事件处理函数中,根据滚动条的状态更新滑块的位置,并重新绘制控件: ```csharp protected override void OnScroll(ScrollEventArgs se) { ...
base.OnScroll(se); // 添加自定义滚动逻辑 } ``` 6. **自定义绘制滚动条** - 虽然.NET Framework内置的`RichTextBox`控件不支持直接自定义滚动条外观,但可以通过继承`RichTextBox`并重写`OnPaint`方法,利用...
17. 滚动条:scroll 18. 内容:content 19. 标签页:tab 20. 文章列表:list 21. 提示信息:msg 22. 小技巧:tips 23. 栏目标题:title 24. 链接:links 25. 页脚:footer 26. 服务:service 27. 热点:hot 28. 新闻...
base.OnValueChanged(value); // 计算内容区域的大小与视口大小的比例 float contentWidthRatio = content.rectTransform.sizeDelta.x / viewport.rect.size.x; float contentHeightRatio = content.rect...
base.OnResize(e); // 计算滚动条的最大值,比如根据列表框的项目数量 ListBox listBox = FindControl("listBox1"); // 假设有一个名为listBox1的列表框 scrollBar.Maximum = listBox.Items.Count; } ``` ### ...
if (scrollState == SCROLL_STATE_IDLE) { // SCROLL_STATE_IDLE 表示已经停止滚动 // 更新适配器数据 adapter.notifyDataSetChanged(); // 设置ListView的当前位置 listView.setSelection(lastItem - 1); } ...
private void ScrollViewer_Scroll(object sender, ScrollEventArgs e) { // 更新内部控件的位置... } ``` 通过以上步骤,我们就成功地为`GroupBox`添加了滚动条功能。这个项目中的代码示例应该包含这些关键部分,...
1. **事件处理**:滚动条的常见事件包括`Scroll`、`ValueChanged`和`DragScroll`。通过重写这些事件的处理函数,可以控制滚动条的行为,比如在用户滚动时执行特定操作。 2. **自定义滑块(Thumb)**:滑块是滚动条...
base.OnDrag(eventData); var contentPosition = this.content.anchoredPosition; // 限制摇杆移动范围在半径内 if (contentPosition.magnitude > mRadius) { contentPosition = contentPosition....
DM_BASE_LAYER_START, DM_NEW_LAYER_START, DM_WALLPAPER, DM_CIRCULAR_MENU1, DM_LIST1, DM_DYNAMIC_LIST1, DM_ASYNCDYNAMIC_LIST1, DM_MATRIX_MENU1, DM_MULTILINE_INPUTBOX1, DM_EMS_INPUTBOX1, DM_DIALER_INPUT_...
卷 (USB)Project 的文件夹 PATH 列表 卷序列号码为 0006EE44 CCBE:F425 I:. │ .project │ pom.xml │ pom.xml~ │ text.txt │ ├─.settings │ org.maven.ide.eclipse.prefs ...│ │ org.eclipse.wst.common....
3. **处理Scroll事件**:当`RichTextBox`滚动时,我们需要更新行号的显示。我们需要监听`Scroll`事件,根据滚动条的位置调整行号的可见部分。 ```csharp private void richTextBox_Scroll(object sender, ...
base.OnPaint(e); // 计算行数 int lineCount = this.GetFirstVisibleLine() + this.Lines.Length; // 绘制行号区域 using (SolidBrush brush = new SolidBrush(this.ForeColor)) { for (int i = this....