Ignore:
Timestamp:
Feb 19, 2014, 6:14:59 AM (10 years ago)
Author:
rvelices
Message:

modus js optims

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/modus/js/thumb.arrange.js

    r26836 r27412  
    1515                if (this.elements.length === 0)
    1616                        this.firstThumbIndex = absIndex;
    17                 if (!$elt.data("w"))
    18                 {
    19                         var w=$elt.width(), h=$elt.height();
     17                var w,h;
     18
     19                if (! (w=$elt.data("w")) ) {
     20                        if ( (w=$elt[0].getAttribute("width")) && (w=parseInt(w)) ) {
     21                                h=parseInt($elt[0].getAttribute("height"));
     22                        }
     23                        else {
     24                                w=$elt.width();
     25                                h=$elt.height();
     26                        }
    2027                        if (h > this.rowHeight) {
    2128                                w = Math.round(w * this.rowHeight/h);
     
    2532                                .data("h", h);
    2633                }
     34                else
     35                        h=$elt.data("h");
     36               
    2737
    2838                var eltObj = {
    2939                        $elt: $elt,
    30                         w: $elt.data("w"),
    31                         h: $elt.data("h")
     40                        w: w,
     41                        h: h
    3242                };
    3343                this.elements.push(eltObj);
     
    166176
    167177        reposition: function($img, imgW, imgH, liW, liH) {
    168                 $img.attr("width", imgW)
    169                         .attr("height", imgH);
     178                /* JQuery .attr and .css functions add too much overhead ...*/
     179                var elt = $img[0];
     180                elt.setAttribute("width", imgW+"");
     181                elt.setAttribute("height", imgH+"");
    170182
    171                 $img.closest("li").css( {
    172                         width: liW+"px",
    173                         height: liH+"px"
    174                 });
     183                elt = elt.parentNode;//a
     184                elt.style.left = Math.round((liW-imgW)/2)+"px";
     185                elt.style.top = Math.round((liH-imgH)/2)+"px";
    175186
    176                 $img.parent("a").css( {
    177                         left: Math.round((liW-imgW)/2)+"px",
    178                         top: Math.round((liH-imgH)/2)+"px"
    179                 });
     187                elt = elt.parentNode;//li
     188                elt.style.width = liW+"px";
     189                elt.style.height = liH+"px";
     190
    180191        }
    181192
Note: See TracChangeset for help on using the changeset viewer.