initial commit
This commit is contained in:
25
node_modules/region-align/.npmignore
generated
vendored
Normal file
25
node_modules/region-align/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# Deployed apps should consider commenting this line out:
|
||||
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
21
node_modules/region-align/LICENSE
generated
vendored
Normal file
21
node_modules/region-align/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Radu Brehar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
8
node_modules/region-align/Makefile
generated
vendored
Normal file
8
node_modules/region-align/Makefile
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
REPORTER = spec
|
||||
|
||||
test:
|
||||
./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --require should
|
||||
test-w:
|
||||
./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --require should --watch
|
||||
|
||||
.PHONY: test test-w
|
||||
4
node_modules/region-align/README.md
generated
vendored
Normal file
4
node_modules/region-align/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
region-align
|
||||
============
|
||||
|
||||
A helper to align rectangular regions in the DOM
|
||||
37
node_modules/region-align/Region.proto.js
generated
vendored
Normal file
37
node_modules/region-align/Region.proto.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
var Region = require('region')
|
||||
|
||||
/**
|
||||
*
|
||||
* Aligns this region to the given region
|
||||
* @param {Region} region
|
||||
* @param {String} alignPositions For available positions, see {@link #getPoint}
|
||||
*
|
||||
* eg: 'tr-bl'
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
Region.prototype.alignToRegion = function(region, alignPositions){
|
||||
Region.align(this, region, alignPositions)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Aligns this region to the given point, in the anchor position
|
||||
* @param {Object} point eg: {x: 20, y: 600}
|
||||
* @param {Number} point.x
|
||||
* @param {Number} point.y
|
||||
*
|
||||
* @param {String} anchor For available positions, see {@link #getPoint}
|
||||
*
|
||||
* eg: 'bl'
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
Region.prototype.alignToPoint = function(point, anchor){
|
||||
Region.alignToPoint(this, point, anchor)
|
||||
|
||||
return this
|
||||
}
|
||||
116
node_modules/region-align/Region.static.js
generated
vendored
Normal file
116
node_modules/region-align/Region.static.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
'use strict'
|
||||
|
||||
var Region = require('region')
|
||||
|
||||
/**
|
||||
* @static
|
||||
* Aligns the source region to the target region, so as to correspond to the given alignment.
|
||||
*
|
||||
* NOTE that this method makes changes on the sourceRegion in order for it to be aligned as specified.
|
||||
*
|
||||
* @param {Region} sourceRegion
|
||||
* @param {Region} targetRegion
|
||||
*
|
||||
* @param {String} align A string with 2 valid align positions, eg: 'tr-bl'.
|
||||
* For valid positions, see {@link Region#getPoint}
|
||||
*
|
||||
* Having 2 regions, we need to be able to align them as we wish:
|
||||
*
|
||||
* for example, if we have
|
||||
*
|
||||
* source target
|
||||
* ________________
|
||||
* ____
|
||||
* | | ________
|
||||
* |____| | |
|
||||
* | |
|
||||
* |________|
|
||||
*
|
||||
* and we align 't-t', we get:
|
||||
*
|
||||
* source target
|
||||
* _________________
|
||||
*
|
||||
* ____ ________
|
||||
* | | | |
|
||||
* |____| | |
|
||||
* |________|
|
||||
*
|
||||
* In this case, the source was moved down to be aligned to the top of the target
|
||||
*
|
||||
*
|
||||
* and if we align 'tc-tc' we get
|
||||
*
|
||||
* source target
|
||||
* __________________
|
||||
*
|
||||
* ________
|
||||
* | | | |
|
||||
* | |____| |
|
||||
* |________|
|
||||
*
|
||||
* Since the source was moved to have the top-center point to be the same with target top-center
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return {RegionClass} The Region class
|
||||
*/
|
||||
Region.align = function(sourceRegion, targetRegion, align){
|
||||
|
||||
targetRegion = Region.from(targetRegion)
|
||||
|
||||
align = (align || 'c-c').split('-')
|
||||
|
||||
//<debug>
|
||||
if (align.length != 2){
|
||||
console.warn('Incorrect region alignment! The align parameter need to be in the form \'br-c\', that is, a - separated string!', align)
|
||||
}
|
||||
//</debug>
|
||||
|
||||
return Region.alignToPoint(sourceRegion, targetRegion.getPoint(align[1]), align[0])
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the given region to be aligned to the point, as specified by anchor
|
||||
*
|
||||
* @param {Region} region The region to align to the point
|
||||
* @param {Object} point The point to be used as a reference
|
||||
* @param {Number} point.x
|
||||
* @param {Number} point.y
|
||||
* @param {String} anchor The position where to anchor the region to the point. See {@link #getPoint} for available options/
|
||||
*
|
||||
* @return {Region} the given region
|
||||
*/
|
||||
Region.alignToPoint = function(region, point, anchor){
|
||||
|
||||
region = Region.from(region)
|
||||
|
||||
var sourcePoint = region.getPoint(anchor)
|
||||
var count = 0
|
||||
var shiftObj = {}
|
||||
|
||||
if (
|
||||
sourcePoint.x != null &&
|
||||
point.x != null
|
||||
){
|
||||
|
||||
count++
|
||||
shiftObj.left = point.x - sourcePoint.x
|
||||
}
|
||||
|
||||
if (
|
||||
sourcePoint.y != null &&
|
||||
point.y != null
|
||||
){
|
||||
count++
|
||||
shiftObj.top = point.y - sourcePoint.y
|
||||
}
|
||||
|
||||
if (count){
|
||||
|
||||
region.shift(shiftObj)
|
||||
|
||||
}
|
||||
|
||||
return region
|
||||
}
|
||||
177
node_modules/region-align/alignToNormalized.js
generated
vendored
Normal file
177
node_modules/region-align/alignToNormalized.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
'use strict'
|
||||
|
||||
var Region = require('region')
|
||||
|
||||
/**
|
||||
*
|
||||
* This method is trying to align the sourceRegion to the targetRegion, given the alignment positions
|
||||
* and the offsets. It only modifies the sourceRegion
|
||||
*
|
||||
* This is all well and easy, but if there is a constrainTo region, the algorithm has to take it into account.
|
||||
* In this case, it works as follows.
|
||||
*
|
||||
* * start with the first alignment position. Aligns the region, adds the offset and then check for the constraint.
|
||||
* * if the constraint condition is ok, return the position.
|
||||
* * otherwise, remember the intersection area, if the regions are intersecting.
|
||||
* * then go to the next specified align position, and so on, computing the maximum intersection area.
|
||||
*
|
||||
* If no alignment fits the constrainRegion, the sourceRegion will be resized to match it,
|
||||
* using the position with the maximum intersection area.
|
||||
*
|
||||
* Since we have computed the index of the position with the max intersection area, take that position,
|
||||
* and align the sourceRegion accordingly. Then resize the sourceRegion to the intersection, and reposition
|
||||
* it again, since resizing it might have destroyed the alignment.
|
||||
*
|
||||
* Return the position.
|
||||
*
|
||||
* @param {Region} sourceRegion
|
||||
* @param {Region} targetRegion
|
||||
* @param {String[]} positions
|
||||
* @param {Object} config
|
||||
* @param {Array} config.offset
|
||||
* @param {Region} config.constrain
|
||||
* @param {Boolean/Object} config.sync
|
||||
*
|
||||
* @return {String/Undefined} the chosen position for the alignment, or undefined if no position found
|
||||
*/
|
||||
function ALIGN_TO_NORMALIZED(sourceRegion, targetRegion, positions, config){
|
||||
|
||||
targetRegion = Region.from(targetRegion)
|
||||
|
||||
config = config || {}
|
||||
|
||||
var constrainTo = config.constrain,
|
||||
syncOption = config.sync,
|
||||
offsets = config.offset || [],
|
||||
syncWidth = false,
|
||||
syncHeight = false,
|
||||
sourceClone = sourceRegion.clone()
|
||||
|
||||
/*
|
||||
* Prepare the method arguments: positions, offsets, constrain and sync options
|
||||
*/
|
||||
if (!Array.isArray(positions)){
|
||||
positions = positions? [positions]: []
|
||||
}
|
||||
|
||||
if (!Array.isArray(offsets)){
|
||||
offsets = offsets? [offsets]: []
|
||||
}
|
||||
|
||||
if (constrainTo){
|
||||
constrainTo = constrainTo === true?
|
||||
Region.getDocRegion():
|
||||
constrainTo.getRegion()
|
||||
}
|
||||
|
||||
if (syncOption){
|
||||
|
||||
if (syncOption.size){
|
||||
syncWidth = true
|
||||
syncHeight = true
|
||||
} else {
|
||||
syncWidth = syncOption === true?
|
||||
true:
|
||||
syncOption.width || false
|
||||
|
||||
syncHeight = syncOption === true?
|
||||
true:
|
||||
syncOption.height || false
|
||||
}
|
||||
}
|
||||
|
||||
if (syncWidth){
|
||||
sourceClone.setWidth(targetRegion.getWidth())
|
||||
}
|
||||
if (syncHeight){
|
||||
sourceClone.setHeight(targetRegion.getHeight())
|
||||
|
||||
}
|
||||
|
||||
var offset,
|
||||
i = 0,
|
||||
len = positions.length,
|
||||
pos,
|
||||
intersection,
|
||||
itArea,
|
||||
maxArea = -1,
|
||||
maxAreaIndex = -1
|
||||
|
||||
for (; i < len; i++){
|
||||
pos = positions[i]
|
||||
offset = offsets[i]
|
||||
|
||||
sourceClone.alignToRegion(targetRegion, pos)
|
||||
|
||||
if (offset){
|
||||
if (!Array.isArray(offset)){
|
||||
offset = offsets[i] = [offset.x || offset.left, offset.y || offset.top]
|
||||
}
|
||||
|
||||
sourceClone.shift({
|
||||
left: offset[0],
|
||||
top : offset[1]
|
||||
})
|
||||
}
|
||||
|
||||
//the source region is already aligned in the correct position
|
||||
|
||||
if (constrainTo){
|
||||
//if we have a constrain region, test for the constrain
|
||||
intersection = sourceClone.getIntersection(constrainTo)
|
||||
|
||||
if ( intersection && intersection.equals(sourceClone) ) {
|
||||
//constrain respected, so return (the aligned position)
|
||||
|
||||
sourceRegion.set(sourceClone)
|
||||
return pos
|
||||
} else {
|
||||
|
||||
//the constrain was not respected, so continue trying
|
||||
if (intersection && ((itArea = intersection.getArea()) > maxArea)){
|
||||
maxArea = itArea
|
||||
maxAreaIndex = i
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
sourceRegion.set(sourceClone)
|
||||
return pos
|
||||
}
|
||||
}
|
||||
|
||||
//no alignment respected the constraints
|
||||
if (~maxAreaIndex){
|
||||
pos = positions[maxAreaIndex]
|
||||
offset = offsets[maxAreaIndex]
|
||||
|
||||
sourceClone.alignToRegion(targetRegion, pos)
|
||||
|
||||
if (offset){
|
||||
sourceClone.shift({
|
||||
left: offset[0],
|
||||
top : offset[1]
|
||||
})
|
||||
}
|
||||
|
||||
//we are sure an intersection exists, because of the way the maxAreaIndex was computed
|
||||
intersection = sourceClone.getIntersection(constrainTo)
|
||||
|
||||
sourceClone.setRegion(intersection)
|
||||
sourceClone.alignToRegion(targetRegion, pos)
|
||||
|
||||
if (offset){
|
||||
sourceClone.shift({
|
||||
left: offset[0],
|
||||
top : offset[1]
|
||||
})
|
||||
}
|
||||
|
||||
sourceRegion.set(sourceClone)
|
||||
|
||||
return pos
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ALIGN_TO_NORMALIZED
|
||||
76
node_modules/region-align/computeAlignRegion.js
generated
vendored
Normal file
76
node_modules/region-align/computeAlignRegion.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
'use strict'
|
||||
|
||||
var ALIGN_TO_NORMALIZED = require('./alignToNormalized')
|
||||
|
||||
var Region = require('region')
|
||||
|
||||
/**
|
||||
* @localdoc Given source and target regions, and the given alignments required, returns a region that is the resulting allignment.
|
||||
* Does not modify the sourceRegion.
|
||||
*
|
||||
* Example
|
||||
*
|
||||
* var sourceRegion = zippy.getInstance({
|
||||
* alias : 'z.region',
|
||||
* top : 10,
|
||||
* left : 10,
|
||||
* bottom : 40,
|
||||
* right : 100
|
||||
* })
|
||||
*
|
||||
* var targetRegion = zippy.getInstance({
|
||||
* alias : 'z.region',
|
||||
* top : 10,
|
||||
* left : 10,
|
||||
* bottom : 40,
|
||||
* right : 100
|
||||
* })
|
||||
* //has top-left at (10,10)
|
||||
* //and bottom-right at (40, 100)
|
||||
*
|
||||
* var alignRegion = alignable.COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, 'tl-br')
|
||||
*
|
||||
* //alignRegion will be a clone of sourceRegion, but will have the
|
||||
* //top-left corner aligned with bottom-right of targetRegion
|
||||
*
|
||||
* alignRegion.get() // => { top: 40, left: 100, bottom: 70, right: 190 }
|
||||
*
|
||||
* @param {Region} sourceRegion The source region to align to targetRegion
|
||||
* @param {Region} targetRegion The target region to which to align the sourceRegion
|
||||
* @param {String/String[]} positions A string ( delimited by "-" characters ) or an array of strings with the position to try, in the order of their priority.
|
||||
* See Region#getPoint for a list of available positions. They can be combined in any way.
|
||||
* @param {Object} config A config object with other configuration for the alignment
|
||||
* @param {Object/Object[]} config.offset Optional offsets. Either an object or an array with a different offset for each position
|
||||
* @param {Element/Region/Boolean} config.constrain The constrain to region or element. If the boolean true, Region.getDocRegion() will be used
|
||||
* @param {Object/Boolean} config.sync A boolean object that indicates whether to sync sourceRegion and targetRegion sizes (width/height or both). Can be
|
||||
*
|
||||
* * true - in order to sync both width and height
|
||||
* * { width: true } - to only sync width
|
||||
* * { height: true } - to only sync height
|
||||
* * { size: true } - to sync both width and height
|
||||
*
|
||||
* @return {Object} an object with the following keys:
|
||||
*
|
||||
* * position - the position where the alignment was made. One of the given positions
|
||||
* * region - the region where the alignment is in place
|
||||
* * positionChanged - boolean value indicating if the position of the returned region is different from the position of sourceRegion
|
||||
* * widthChanged - boolean value indicating if the width of the returned region is different from the width of sourceRegion
|
||||
* * heightChanged - boolean value indicating if the height of the returned region is different from the height of sourceRegion
|
||||
*/
|
||||
function COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config){
|
||||
sourceRegion = Region.from(sourceRegion)
|
||||
|
||||
var sourceClone = sourceRegion.clone()
|
||||
var position = ALIGN_TO_NORMALIZED(sourceClone, targetRegion, positions, config)
|
||||
|
||||
return {
|
||||
position : position,
|
||||
region : sourceClone,
|
||||
widthChanged : sourceClone.getWidth() != sourceRegion.getWidth(),
|
||||
heightChanged : sourceClone.getHeight() != sourceRegion.getHeight(),
|
||||
positionChanged : sourceClone.equalsPosition(sourceRegion)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = COMPUTE_ALIGN_REGION
|
||||
181
node_modules/region-align/index.js
generated
vendored
Normal file
181
node_modules/region-align/index.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
'use strict';
|
||||
|
||||
var Region = require('region')
|
||||
|
||||
require('./Region.static')
|
||||
require('./Region.proto')
|
||||
|
||||
var COMPUTE_ALIGN_REGION = require('./computeAlignRegion')
|
||||
|
||||
/**
|
||||
* region-align module exposes methods for aligning {@link Element} and {@link Region} instances
|
||||
*
|
||||
* The #alignTo method aligns this to the target element/region using the specified positions. See #alignTo for a graphical example.
|
||||
*
|
||||
*
|
||||
* var div = Element.select('div.first')
|
||||
*
|
||||
* div.alignTo(Element.select('body') , 'br-br')
|
||||
*
|
||||
* //aligns the div to be in the bottom-right corner of the body
|
||||
*
|
||||
* Other useful methods
|
||||
*
|
||||
* * {@link #alignRegions} - aligns a given source region to a target region
|
||||
* * {@link #COMPUTE_ALIGN_REGION} - given a source region and a target region, and alignment positions, returns a clone of the source region, but aligned to satisfy the given alignments
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Aligns sourceRegion to targetRegion. It modifies the sourceRegion in order to perform the correct alignment.
|
||||
* See #COMPUTE_ALIGN_REGION for details and examples.
|
||||
*
|
||||
* This method calls #COMPUTE_ALIGN_REGION passing to it all its arguments. The #COMPUTE_ALIGN_REGION method returns a region that is properly aligned.
|
||||
* If this returned region position/size differs from sourceRegion, then the sourceRegion is modified to be an exact copy of the aligned region.
|
||||
*
|
||||
* @inheritdoc #COMPUTE_ALIGN_REGION
|
||||
* @return {String} the position used for alignment
|
||||
*/
|
||||
Region.alignRegions = function(sourceRegion, targetRegion, positions, config){
|
||||
|
||||
var result = COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config)
|
||||
var alignedRegion = result.region
|
||||
|
||||
if ( !alignedRegion.equals(sourceRegion) ) {
|
||||
sourceRegion.setRegion(alignedRegion)
|
||||
}
|
||||
|
||||
return result.position
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The #alignTo method aligns this to the given target region, using the specified alignment position(s).
|
||||
* You can also specify a constrain for the alignment.
|
||||
*
|
||||
* Example
|
||||
*
|
||||
* BIG
|
||||
* ________________________
|
||||
* | _______ |
|
||||
* | | | |
|
||||
* | | A | |
|
||||
* | | | _____ |
|
||||
* | |_______| | | |
|
||||
* | | B | |
|
||||
* | | | |
|
||||
* |_______________|_____|_|
|
||||
*
|
||||
* Assume the *BIG* outside rectangle is our constrain region, and you want to align the *A* rectangle
|
||||
* to the *B* rectangle. Ideally, you'll want their tops to be aligned, and *A* to be placed at the right side of *B*
|
||||
*
|
||||
*
|
||||
* //so we would align them using
|
||||
*
|
||||
* A.alignTo(B, 'tl-tr', { constrain: BIG })
|
||||
*
|
||||
* But this would result in
|
||||
*
|
||||
* BIG
|
||||
* ________________________
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | _____ _|_____
|
||||
* | | | . |
|
||||
* | | B | . A |
|
||||
* | | | . |
|
||||
* |_______________|_____|_._____|
|
||||
*
|
||||
*
|
||||
* Which is not what we want. So we specify an array of options to try
|
||||
*
|
||||
* A.alignTo(B, ['tl-tr', 'tr-tl'], { constrain: BIG })
|
||||
*
|
||||
* So by this we mean: try to align A(top,left) with B(top,right) and stick to the BIG constrain. If this is not possible,
|
||||
* try the next option: align A(top,right) with B(top,left)
|
||||
*
|
||||
* So this is what we end up with
|
||||
*
|
||||
* BIG
|
||||
* ________________________
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | _______ _____ |
|
||||
* | | | | |
|
||||
* | | A | B | |
|
||||
* | | | | |
|
||||
* |_______|_______|_____|_|
|
||||
*
|
||||
*
|
||||
* Which is a lot better!
|
||||
*
|
||||
* @param {Element/Region} target The target to which to align this alignable.
|
||||
*
|
||||
* @param {String[]/String} positions The positions for the alignment.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 'br-tl'
|
||||
* ['br-tl','br-tr','cx-tc']
|
||||
*
|
||||
* This method will try to align using the first position. But if there is a constrain region, that position might not satisfy the constrain.
|
||||
* If this is the case, the next positions will be tried. If one of them satifies the constrain, it will be used for aligning and it will be returned from this method.
|
||||
*
|
||||
* If no position matches the contrain, the one with the largest intersection of the source region with the constrain will be used, and this alignable will be resized to fit the constrain region.
|
||||
*
|
||||
* @param {Object} config A config object with other configuration for this method
|
||||
*
|
||||
* @param {Array[]/Object[]/Object} config.offset The offset to use for aligning. If more that one offset is specified, then offset at a given index is used with the position at the same index.
|
||||
*
|
||||
* An offset can have the following form:
|
||||
*
|
||||
* [left_offset, top_offset]
|
||||
* {left: left_offset, top: top_offset}
|
||||
* {x: left_offset, y: top_offset}
|
||||
*
|
||||
* You can pass one offset or an array of offsets. In case you pass just one offset,
|
||||
* it cannot have the array form, so you cannot call
|
||||
*
|
||||
* this.alignTo(target, positions, [10, 20])
|
||||
*
|
||||
* If you do, it will not be considered. Instead, please use
|
||||
*
|
||||
* this.alignTo(target, positions, {x: 10, y: 20})
|
||||
*
|
||||
* Or
|
||||
*
|
||||
* this.alignTo(target, positions, [[10, 20]] )
|
||||
*
|
||||
* @param {Boolean/Element/Region} config.constrain If boolean, target will be constrained to the document region, otherwise,
|
||||
* getRegion will be called on this argument to determine the region we need to constrain to.
|
||||
*
|
||||
* @param {Boolean/Object} config.sync Either boolean or an object with {width, height}. If it is boolean,
|
||||
* both width and height will be synced. If directions are specified, will only sync the direction which is specified as true
|
||||
*
|
||||
* @return {String}
|
||||
*
|
||||
*/
|
||||
Region.prototype.alignTo = function(target, positions, config){
|
||||
|
||||
config = config || {}
|
||||
|
||||
var sourceRegion = this
|
||||
var targetRegion = Region.from(target)
|
||||
|
||||
var result = COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config)
|
||||
var resultRegion = result.region
|
||||
|
||||
if (!resultRegion.equalsSize(sourceRegion)){
|
||||
this.setSize(resultRegion.getSize())
|
||||
}
|
||||
if (!resultRegion.equalsPosition(sourceRegion)){
|
||||
this.setPosition(resultRegion.getPosition(), { absolute: !!config.absolute })
|
||||
}
|
||||
|
||||
return result.position
|
||||
}
|
||||
|
||||
module.exports = Region
|
||||
36
node_modules/region-align/package.json
generated
vendored
Normal file
36
node_modules/region-align/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "region-align",
|
||||
"version": "2.1.3",
|
||||
"description": "A helper to align rectangular regions in the DOM",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "make test",
|
||||
"test-w": "make test-w",
|
||||
"test-debug": "mocha --debug-brk"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~1.21.0",
|
||||
"should": "~4.0.4"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/radubrehar/region-align.git"
|
||||
},
|
||||
"keywords": [
|
||||
"align",
|
||||
"region",
|
||||
"rectangle",
|
||||
"dom",
|
||||
"html",
|
||||
"element"
|
||||
],
|
||||
"author": "Radu Brehar",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/radubrehar/region-align/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-assign": "^4.0.1",
|
||||
"region": "^2.1.2"
|
||||
}
|
||||
}
|
||||
9
node_modules/region-align/region-align.sublime-project
generated
vendored
Normal file
9
node_modules/region-align/region-align.sublime-project
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"follow_symlinks": true,
|
||||
"path": "."
|
||||
}
|
||||
]
|
||||
}
|
||||
2150
node_modules/region-align/region-align.sublime-workspace
generated
vendored
Normal file
2150
node_modules/region-align/region-align.sublime-workspace
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user