[OpenLayers-Trac] Re: [OpenLayers] #2906: Panel: Simplify the
method "redraw"
OpenLayers
trac-20090302 at openlayers.org
Thu Mar 17 04:05:09 EDT 2011
#2906: Panel: Simplify the method "redraw"
---------------------------+------------------------------------------------
Reporter: jorix | Owner: erilem
Type: feature | Status: new
Priority: minor | Milestone: 2.11 Release
Component: Control.Panel | Version: 2.10
Keywords: | State: Review
---------------------------+------------------------------------------------
Comment(by erilem):
The description of the ticket says "But to activate/deactivate a single
control is not necessary to rewrite all the icons, just need to change the
className of div of the icon". I don't think that statement is correct.
When a control is activated or deactivated the appearance of every control
is to be changed.
That being said, I think it makes great sense not to remove/add DOM
elements multiple times each time a control is activated or deactivated. I
guess the patch could just involve rewriting redraw like this:
{{{
redraw: function(brutal) {
if(brutal) {
for (var l=this.div.childNodes.length, i=l-1; i>=0; i--) {
this.div.removeChild(this.div.childNodes[i]);
}
this.div.innerHTML = "";
}
if (this.active) {
for (var i=0, len=this.controls.length; i<len; i++) {
var element = this.controls[i].panel_div;
if (this.controls[i].active) {
element.className = this.controls[i].displayClass +
"ItemActive";
} else {
element.className = this.controls[i].displayClass +
"ItemInactive";
}
if (brutal) {
this.div.appendChild(element);
}
}
}
},
}}}
and calling {{{redraw(true)}}} where appropriate.
What do you think?
--
Ticket URL: <http://trac.openlayers.org/ticket/2906#comment:4>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list