Results 1 to 1 of 1

Thread: Chromemenu within absolute or relative positioned div's

  1. #1
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Chromemenu within absolute or relative positioned div's

    1) Script Title: Chromemenu within absolute or relative positioned div's

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...rome/index.htm

    3) Describe problem:
    When putting a chromemenu within an absolute ore relative positioned DIV, the prsition calculation did not work properly so that the menu is popped up on a wrong position.

    I have made a chang in the positionning function so that the calculation stops when the offset element is absolutely or relatively positioned:

    Code:
    measure: function(el, styleProp) {
    	var st;
    	if (el.currentStyle)
    		st = el.currentStyle[styleProp];
    	else if (window.getComputedStyle)
    		st = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
    	return st;
    },
    
    getposOffset:function(what, offsettype){
    	var pos;
    	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    	var parentEl=what.offsetParent;
    	while (parentEl!=null){
    		pos=this.measure(parentEl, 'position');
    		if (pos=='absolute' || pos=='relative') {
    			break;
    		}
    		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    		parentEl=parentEl.offsetParent;
    	}
    	return totaloffset;
    },
    This works fine now.

    Thomas
    Last edited by tjakober; 02-16-2010 at 06:26 PM. Reason: Code did not work properly

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •