Plugin Directory

Changeset 772730


Ignore:
Timestamp:
09/15/2013 02:34:49 PM (11 years ago)
Author:
fmos
Message:

Fixed whitespace on container resize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-photonav/trunk/jquery.photonav.js

    r772727 r772730  
    4040        };
    4141
    42         /* PhotoNav DOM tree notes
    43 
    44            .photonav -> .container -> .content -> .image
    45 
    46            .image is wrapped in .content for uniformity with the drag360 mode,
    47            where the image is assigned as x-repeat background of .content
    48 
    49            .container is separate from .photonav, because the .photonav comprises
    50            two .containers: one for inline view and one for popup/lightbox view
    51 
    52          */
    53 
    5442        this.initMove = function(container) {
    5543            var content = container.find('.content');
     
    10896        // Parse the position parameters
    10997        this.parsePos = function(position, dimage, dcontainer) {
    110             if (position == 'center') {
    111                 result = (dcontainer - dimage) / 2;
    112             } else if (position == 'left') {
    113                 result = (dcontainer - dimage);
    114             } else if (position == 'right') {
    115                 result = 0;
    116             } else {
    117                 result = parseFloat(position);
     98            var result;
     99            switch (position) {
     100                case 'center':
     101                    result = (dcontainer - dimage) / 2;
     102                    break;
     103                case 'left':
     104                case 'top':
     105                    result = (dcontainer - dimage);
     106                    break;
     107                case 'right':
     108                case 'bottom':
     109                    result = 0;
     110                    break;
     111                default:
     112                    result = parseFloat(position);
     113                    break;
    118114            }
    119115            return result;
     
    133129            content.css('top', Math.min(0, (ch - ih)/2));
    134130            if (callback) callback(container, content, iw, ih, cw, ch);
     131            $(window).resize(function() {
     132                if ((container.width() != cw) || (container.height() != ch)) {
     133                    cw = container.width(); ch = container.height();
     134                    var pos = content.position();
     135                    if (pos.left < cw - iw) content.css('left', cw - iw);
     136                    if (pos.top < ch - ih) content.css('top', ch - ih);
     137                    if (callback) callback(container, content, iw, ih, cw, ch);
     138                }
     139            });
    135140            if (config.animate == '1') {
    136141                content.each(
Note: See TracChangeset for help on using the changeset viewer.