弹出菜单(有弹出过程)

转载 2006年05月25日 09:22:00

下边是调用方法
ypSlideOutMenu("aboutus", "down", 75, 120, 88, 84);
id,方向,左边坐标,右边坐标,宽度,高度

 


<script language="javascript">
/*****************************************************
* a nice little script to create exclusive, slide-out
* menus for ns4, ns6, mozilla, opera, ie4, ie5 on
* mac and win32. I've got no linux or unix to test on but
* it should(?) work...
*
* Revised:
* - 08/29/2002 : added .hideAll()
*
* --youngpup--
//new ypSlideOutMenu("aboutus", "down", 75, 120, 88, 84);
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 250
ypSlideOutMenu.hideDelay = 1000
ypSlideOutMenu.minCPUResolution = 10
// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
this.ie = document.all ? 1 : 0
this.ns4 = document.layers ? 1 : 0
this.dom = document.getElementById ? 1 : 0
if (this.ie || this.ns4 || this.dom) {
this.id = id
this.dir = dir
this.orientation = dir == "left" || dir == "right" ? "h" : "v"
this.dirType = dir == "right" || dir == "down" ? "-" : "+"
this.dim = this.orientation == "h" ? width : height
this.hideTimer = false
this.aniTimer = false
this.open = false
this.over = false
this.startTime = 0
this.gRef = "ypSlideOutMenu_"+id
eval(this.gRef+"=this")
ypSlideOutMenu.Registry[id] = this
var d = document
var strCSS = '<style type="text/css">';
strCSS += '#' + this.id + 'Container { visibility:hidden; '
strCSS += 'left:' + left + 'px; '
strCSS += 'top:' + top + 'px; '
strCSS += 'overflow:hidden; z-index:10000; }'
strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
strCSS += 'width:' + width + 'px; '
strCSS += 'height:' + height + 'px; '
strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
strCSS += '}'
strCSS += '</style>'
d.write(strCSS)
this.load()
}
}
ypSlideOutMenu.prototype.load = function() {
var d = document
var lyrId1 = this.id + "Container"
var lyrId2 = this.id + "Content"
var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
var temp
if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
else {
this.container = obj1
this.menu = obj2
this.style = this.ns4 ? this.menu : this.menu.style
this.homePos = eval("0" + this.dirType + this.dim)
this.outPos = 0
this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen
// set event handlers.
if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
//set initial state
this.endSlide()
}
}
ypSlideOutMenu.showMenu = function(id)
{
var reg = ypSlideOutMenu.Registry
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
obj.over = true
for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)
if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
}
}
ypSlideOutMenu.hideMenu = function(id)
{
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
}
}
ypSlideOutMenu.hideAll = function()
{
var reg = ypSlideOutMenu.Registry
for (menu in reg) {
ypSlideOutMenu.hide(menu);
if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
}
}
ypSlideOutMenu.hide = function(id)
{
var obj = ypSlideOutMenu.Registry[id]
obj.over = false
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
obj.hideTimer = 0
if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutMenu.prototype.startSlide = function(open) {
this[open ? "onactivate" : "ondeactivate"]()
this.open = open
if (open) this.setVisibility(true)
this.startTime = (new Date()).getTime()
this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}
ypSlideOutMenu.prototype.slide = function() {
var elapsed = (new Date()).getTime() - this.startTime
if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
else {
var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
if (this.open && this.dirType == "-") d = -d
else if (this.open && this.dirType == "+") d = -d
else if (!this.open && this.dirType == "-") d = -this.dim + d
else d = this.dim + d
this.moveTo(d)
}
}
ypSlideOutMenu.prototype.endSlide = function() {
this.aniTimer = window.clearTimeout(this.aniTimer)
this.moveTo(this.open ? this.outPos : this.homePos)
if (!this.open) this.setVisibility(false)
if ((this.open && !this.over) || (!this.open && this.over)) {
this.startSlide(this.over)
}
}
ypSlideOutMenu.prototype.setVisibility = function(bShow) {
var s = this.ns4 ? this.container : this.container.style
s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) {
this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
return parseInt(this.style[c])
}
ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }
</script>

MFC中教你怎么编写弹出式菜单

在VS2008中,不能像VC++6.0那样通过Compnents and Controls来自动添加弹出式菜单,需要手动添加。可以采用两种方式创建弹出式菜单。 一、利用现有的菜单资源创建 (1)首...
  • jiadabin
  • jiadabin
  • 2014年03月31日 18:27
  • 2054

MFC实现弹出式快捷菜单/右键菜单

方法1: void CMyView::OnRButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler c...
  • chuan442616909
  • chuan442616909
  • 2013年08月08日 20:51
  • 539

MFC 添加右键弹出式菜单

1.在资源窗口插入菜单,编辑菜单。(菜单名称后面加(&字母)就是快捷键) 菜单每一项都有一个ID,可以在菜单窗口查看。 3.在对话框右键 > 事件 里面添加OnContextMenu...
  • hddygs001
  • hddygs001
  • 2010年06月25日 19:28
  • 3049

弹出式菜单的编写

效果展示 PopMenu的定义 PopMenu的实现 属性的定义 位置的调整 隐藏菜单 响应菜单点击 显示菜单 坐标定义 分割屏幕 蒙版路径 结束 在QQ、微信的消息页面,右上角有一个“+”号,点...
  • cairo123
  • cairo123
  • 2017年04月04日 15:58
  • 260

Android中实现底部弹出菜单栏

今天闲的没事写了一个底部弹出菜单栏,虽然很简单,但是为了以后方便用,索性还是写下来了,那好,我们先看一下实现效果吧,我想这种效果现在用的实在是太多了(点击按钮显示底部菜单栏,然后单击空白地方隐藏菜单栏...
  • xys199719
  • xys199719
  • 2016年12月09日 14:14
  • 4877

java右键弹出菜单

package test1; import java.awt.*; import java.awt.event.*; import java.applet.*; public class Applet...
  • bailang71
  • bailang71
  • 2004年12月13日 08:25
  • 1199

android 页面底部弹出菜单(dialog)

列举两种方法: 方法一:使用dialog(背景会变暗) private void showDialog(Context context, @LayoutRes int resource) { ...
  • m940034240
  • m940034240
  • 2017年08月04日 16:57
  • 323

android底部弹出菜单

现在越来越多的项目用到底部弹出样式的菜单,为了方便使用,现将该控件封装成一通用控件。话不多说,先来效果图: 下面是具体实现:    1.编写菜单布局,界面布局主要是页面底部三个菜单按钮,当...
  • lyq_mufeng
  • lyq_mufeng
  • 2015年07月27日 14:03
  • 5576

PopupWindow实现右侧、左侧和底部弹出菜单

先上图,4张:
  • jianfengwen
  • jianfengwen
  • 2015年09月21日 17:10
  • 22195

Android之PopupWindow类似微信右上角的弹出菜单

日常开发过程中对于PopupWindown的使用也是比较多的。这里给大家展示一下PopupWindow的使用。 修改activity_main.xml布局: ...
  • LoveYaozu
  • LoveYaozu
  • 2016年04月14日 12:15
  • 6585
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:弹出菜单(有弹出过程)
举报原因:
原因补充:

(最多只允许输入30个字)