Skip to content

Commit

Permalink
👷‍♀️ build v4.2.2; 🛠 use float values for position
Browse files Browse the repository at this point in the history
⬆️ update dependencies
+ outlayer v2.1.1. #795
+ fizzy-ui-utils v2.0.7
+ get-size v2.0.3
  • Loading branch information
desandro committed Jul 4, 2018
1 parent 31113c7 commit 3b0883c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
88 changes: 45 additions & 43 deletions dist/masonry.pkgd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Masonry PACKAGED v4.2.1
* Masonry PACKAGED v4.2.2
* Cascading grid layout library
* https://masonry.desandro.com
* MIT License
Expand Down Expand Up @@ -264,22 +264,19 @@ return EvEmitter;
}));

/*!
* getSize v2.0.2
* getSize v2.0.3
* measure size of elements
* MIT license
*/

/*jshint browser: true, strict: true, undef: true, unused: true */
/*global define: false, module: false, console: false */
/* jshint browser: true, strict: true, undef: true, unused: true */
/* globals console: false */

( function( window, factory ) {
'use strict';

/* jshint strict: false */ /* globals define, module */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'get-size/get-size',[],function() {
return factory();
});
define( 'get-size/get-size',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory();
Expand Down Expand Up @@ -354,7 +351,7 @@ function getStyle( elem ) {
if ( !style ) {
logError( 'Style returned ' + style +
'. Are you running this code in a hidden iframe on Firefox? ' +
'See http://bit.ly/getsizebug1' );
'See https://bit.ly/getsizebug1' );
}
return style;
}
Expand All @@ -380,8 +377,8 @@ function setup() {
// -------------------------- box sizing -------------------------- //

/**
* WebKit measures the outer-width on style.width on border-box elems
* IE & Firefox<29 measures the inner-width
* Chrome & Safari measure the outer-width on style.width on border-box elems
* IE11 & Firefox<29 measures the inner-width
*/
var div = document.createElement('div');
div.style.width = '200px';
Expand All @@ -393,10 +390,11 @@ function setup() {
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
// round value for browser zoom. desandro/masonry#928
isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
getSize.isBoxSizeOuter = isBoxSizeOuter;

getSize.isBoxSizeOuter = isBoxSizeOuter = getStyleSize( style.width ) == 200;
body.removeChild( div );

}

// -------------------------- getSize -------------------------- //
Expand Down Expand Up @@ -528,7 +526,7 @@ return getSize;
}));

/**
* Fizzy UI utils v2.0.5
* Fizzy UI utils v2.0.7
* MIT license
*/

Expand Down Expand Up @@ -583,23 +581,27 @@ utils.modulo = function( num, div ) {

// ----- makeArray ----- //

var arraySlice = Array.prototype.slice;

// turn element or nodeList into an array
utils.makeArray = function( obj ) {
var ary = [];
if ( Array.isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( obj && typeof obj == 'object' &&
typeof obj.length == 'number' ) {
return obj;
}
// return empty array if undefined or null. #6
if ( obj === null || obj === undefined ) {
return [];
}

var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
for ( var i=0; i < obj.length; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
return arraySlice.call( obj );
}
return ary;

// array of single index
return [ obj ];
};

// ----- removeFrom ----- //
Expand Down Expand Up @@ -678,22 +680,21 @@ utils.filterFindElements = function( elems, selector ) {
// ----- debounceMethod ----- //

utils.debounceMethod = function( _class, methodName, threshold ) {
threshold = threshold || 100;
// original method
var method = _class.prototype[ methodName ];
var timeoutName = methodName + 'Timeout';

_class.prototype[ methodName ] = function() {
var timeout = this[ timeoutName ];
if ( timeout ) {
clearTimeout( timeout );
}
var args = arguments;
clearTimeout( timeout );

var args = arguments;
var _this = this;
this[ timeoutName ] = setTimeout( function() {
method.apply( _this, args );
delete _this[ timeoutName ];
}, threshold || 100 );
}, threshold );
};
};

Expand Down Expand Up @@ -901,13 +902,16 @@ proto.getPosition = function() {
var isOriginTop = this.layout._getOption('originTop');
var xValue = style[ isOriginLeft ? 'left' : 'right' ];
var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
var x = parseFloat( xValue );
var y = parseFloat( yValue );
// convert percent to pixels
var layoutSize = this.layout.size;
var x = xValue.indexOf('%') != -1 ?
( parseFloat( xValue ) / 100 ) * layoutSize.width : parseInt( xValue, 10 );
var y = yValue.indexOf('%') != -1 ?
( parseFloat( yValue ) / 100 ) * layoutSize.height : parseInt( yValue, 10 );

if ( xValue.indexOf('%') != -1 ) {
x = ( x / 100 ) * layoutSize.width;
}
if ( yValue.indexOf('%') != -1 ) {
y = ( y / 100 ) * layoutSize.height;
}
// clean up 'auto' or other non-integer values
x = isNaN( x ) ? 0 : x;
y = isNaN( y ) ? 0 : y;
Expand Down Expand Up @@ -970,9 +974,7 @@ proto._transitionTo = function( x, y ) {
var curX = this.position.x;
var curY = this.position.y;

var compareX = parseInt( x, 10 );
var compareY = parseInt( y, 10 );
var didNotMove = compareX === this.position.x && compareY === this.position.y;
var didNotMove = x == this.position.x && y == this.position.y;

// save end position
this.setPosition( x, y );
Expand Down Expand Up @@ -1015,8 +1017,8 @@ proto.goTo = function( x, y ) {
proto.moveTo = proto._transitionTo;

proto.setPosition = function( x, y ) {
this.position.x = parseInt( x, 10 );
this.position.y = parseInt( y, 10 );
this.position.x = parseFloat( x );
this.position.y = parseFloat( y );
};

// ----- transition ----- //
Expand Down Expand Up @@ -1321,7 +1323,7 @@ return Item;
}));

/*!
* Outlayer v2.1.0
* Outlayer v2.1.1
* the brains and guts of a layout library
* MIT license
*/
Expand Down Expand Up @@ -2261,7 +2263,7 @@ return Outlayer;
}));

/*!
* Masonry v4.2.1
* Masonry v4.2.2
* Cascading grid layout library
* https://masonry.desandro.com
* MIT License
Expand Down
Loading

0 comments on commit 3b0883c

Please sign in to comment.