in partnership with mediatemple

Ticket #935 (closed defect: invalid)

Opened 2 months ago

Last modified 3 days ago

Element.Properties.opacity.get retrieves opacity from element's storage and not necessarily current opacity

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

Description

Element.Properties.opacity.get retrieves opacity from storage, and unlike getComputedStyle it cannot retrieve current opacity unless set by Element.Properties.opacity.set.

Could it always read from style like getComputedStyle does?

Code example:

if (Browser.Engine.trident) return this.filters.alpha ? this.filters.alpha.opacity : 1
else return +this.getComputedStyle("opacity") || 1;

Thanks

Change History

Changed 2 months ago by Devign

  • summary changed from Element.Properties.opacity.get retrieves opacity from element's storage and not necessary current opacity to Element.Properties.opacity.get retrieves opacity from element's storage and not necessarily current opacity

Changed 4 days ago by tomocchino

  • status changed from new to closed
  • resolution set to invalid

In order to avoid browser inconsistencies you should always set opacity using MooTools... in this sense, the opacity accessor is only for use with elements that have had their opacity set by MooTools

Changed 3 days ago by Devign

  • status changed from closed to reopened
  • resolution deleted

But sometimes I have it my CSS, so when the page is loaded elements should be semi transparent. Setting opacity when dom is ready can cause a flicker.
In all modern browsers the following will work (filter/zoom for IE, opecity for the rest).

div {
	opacity:.4;
	filter:alpha(opacity=40);
	zoom:1;
	background-color:#669CB9;
}

Changed 3 days ago by tomocchino

  • status changed from reopened to closed
  • resolution set to invalid

Then for now i would suggest setting it in your CSS, and then using the setter to set it to the same value after the dom is ready. The patch will not be added before the 1.2 release, but we may look into it for 1.3.

Note: See TracTickets for help on using tickets.