Changeset 12679 for extensions/GThumb/js


Ignore:
Timestamp:
Dec 1, 2011, 3:25:47 PM (12 years ago)
Author:
patdenice
Message:

Display is better whith 1 or 2 lines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GThumb/js/gthumb.js

    r12678 r12679  
    7878        width_count = this.margin;
    7979        height = this.margin;
     80        max_height = 0;
    8081        available_width = main_width - (width + this.margin);
    8182        line = 1;
     
    8384
    8485          width_count += this.t[i].width + this.margin;
     86          max_height = Math.max(this.t[i].height, max_height);
    8587
    8688          if (width_count > available_width) {
    8789            ratio = width_count / available_width;
    88             height += Math.round(this.t[i].height / ratio);
     90            height += Math.round(max_height / ratio);
    8991            line++;
     92            max_height = 0;
    9093            width_count = this.margin;
    9194            if (line > 2) {
    92               if (height > best_size.height && width/height > min_ratio && height<=this.big_thumb.height) {
     95              if (height >= best_size.height && width/height >= min_ratio && height<=this.big_thumb.height) {
    9396                best_size = {width:width,height:height}
    9497              }
     
    98101        }
    99102        if (line <= 2) {
    100           best_size = {width:width,height:this.big_thumb.height};
     103          if (max_height == 0 || line == 1) {
     104            height = this.big_thumb.height;
     105          } else {
     106            height += max_height;
     107          }
     108          if (height >= best_size.height && width/height >= min_ratio && height<=this.big_thumb.height) {
     109            best_size = {width:width,height:height}
     110          }
    101111        }
    102112      }
Note: See TracChangeset for help on using the changeset viewer.