弹出窗口固定它的位置

时间:2014-04-23 07:48:11

标签: gwt popup jsni

我有一个弹出窗口,它的位置是根据屏幕动态设置的,但是当标签的数量增加时,弹出窗口会产生问题,就像它在上面显示的那样,当标签在scolling窗口上显示时,它会假设下来但它没有下来。

                 var position= popup.offsetTop;
                 alert("popupTop"+position);
                 var positionpop=popup.offsetHeight;   
                 var width1=label.offsetWidth;
                 var position1=label.offsetHeight;
                 var position2=label.offsetTop;         
                 var windowHeight = $wnd.innerHeight;
                 var scroll=$wnd.pageYOffset;
                 alert(scroll+"scroll");
                 var t=position-scroll;
                 var z=windowHeight-scroll;

                 var x="Totalheight"+screen.height; 
                 var y=position1+position2+positionpop;      
                 if(position1+position2+positionpop<windowHeight)
                 {
                    alert("no change");
                 }


                      if(position1+position2+positionpop>windowHeight )
                      { 
                       popup.setAttribute("style","top:"+(position2-positionpop)+"px");
                       } 

                 if(t<=0 || z<=0)
                 {

                   popup.setAttribute("style","bottom:"+(diff)+"px");
                 }

2 个答案:

答案 0 :(得分:1)

当标签位于顶部时,我已达到上下动态改变位置但仍然存在一个问题,即我一个接一个地上下位置我想将它绑定到一个......

                   if(position2+positionpop<windowHeight || t<=0)
                 {
                     popup.setAttribute("style","bottom:"+((windowHeight-(position2+position1))-positionpop)+"px");
                 }
                 else
                  {
                  if(position2+positionpop>windowHeight && t>0)
                  { 
                   popup.setAttribute("style","top:"+(position2-positionpop)+"px");
                  } 
                  }                                                                                                                                                                                                                                                                                                       

答案 1 :(得分:0)

您应该使用PopupPanel.setPopupPositionAndShowPopupPanel.setPopupPosition。请参阅PopupPanel javadoc sample