in partnership with mediatemple

Ticket #616 (reopened defect)

Opened 6 months ago

Last modified 2 weeks ago

getPosition() returns wrong values in Opera

Reported by: lebowski Owned by:
Type: defect Priority: minor
Milestone: Mootools version 1.2 Component: Core
Keywords: Cc:

Description

Opera seems to have some problems with getPosition() and inline elements.

Here's a simple example:

<div>
  <image src="" id="img1" style="width:20px;height:20px;" alt="1" />
  <image src="" id="img2" style="width:20px;height:20px;" alt="2" />
  <a href="#"><image src="" id="img3" style="width:20px;height:20px;" alt="3" /></a>
  <a href="#"><image src="" id="img4" style="width:20px;height:20px;" alt="4" /></a>
</div>
window.addEvent('domready', function() {
  alert(
    '\n img1.x = ' + $('img1').getPosition().x +
    '\n img2.x = ' + $('img2').getPosition().x +
    '\n img3.x = ' + $('img3').getPosition().x +
    '\n img4.x = ' + $('img4').getPosition().x
  );
});

When setting all the margin/padding and borders to 0px (via css) and ignoring all the spaces and line breaks between the images, the expected values should be:

img1.x = 0
img2.x = 20
img3.x = 40
img4.x = 60
(Because these img-tags all should be in one line.)

Firefox and Safari return the correct values, but Opera did not. Opera returns:

img1.x = 0
img2.x = 20
img3.x = 0 -> wrong
img4.x = 0 -> wrong

Opera might have a problem with these anchor (inline) tags.

Browsers: Opera 9.24 (Mac), Safari 3.0 (Mac) and Firefox 2.0.0.9 (Mac)
Mootools: version 1.2b1

Change History

Changed 3 months ago by w00fz

  • priority changed from trivial to minor
  • resolution set to fixed
  • status changed from new to closed
  • component changed from Plugins to Core

Should be fixed in [1355]. Please, reopen if it's not.

Changed 2 weeks ago by hthetiot

  • status changed from closed to reopened
  • resolution deleted

bug allways here :

to fix :

	getPosition: function(relative){
		if (isBody(this)) return {x: 0, y: 0};
		var offset = this.getOffsets(), scroll = this.getScrolls();
		var position = {x: offset.x - scroll.x, y: offset.y - scroll.y};
		var relativePosition = (relative && (relative = $(relative))) ? relative.getPosition() : {x: 0, y: 0};

        if (Browser.Engine.presto925) {
            var position = {x: offset.x, y: offset.y};
        }

		return {x: position.x - relativePosition.x, y: position.y - relativePosition.y};
	},
Note: See TracTickets for help on using tickets.