get-window-offset
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _getScrollInfo = require('get-scroll-info'); | ||
@@ -20,2 +22,6 @@ | ||
var _isFixed = require('./isFixed'); | ||
var _isFixed2 = _interopRequireDefault(_isFixed); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -25,23 +31,10 @@ | ||
var getWindowOffset = function getWindowOffset(dom) { | ||
var calWindowOffset = function calWindowOffset(domInfo, scrollInfo) { | ||
var _distanceFlip; | ||
if (!dom) { | ||
console.error('getWindowOffset not assign dom'); | ||
console.trace(); | ||
return false; | ||
} | ||
var domInfo = (0, _getoffset2.default)(dom); | ||
var scrollInfo = (0, _getScrollInfo2.default)(); | ||
domInfo = (0, _isOnScreen2.default)(domInfo, scrollInfo); | ||
var distance = {}; | ||
if (domInfo.isOnScreen) { | ||
distance.top = Math.abs(domInfo.top - scrollInfo.top); | ||
distance.right = Math.abs(domInfo.right - scrollInfo.right); | ||
distance.bottom = Math.abs(domInfo.bottom - scrollInfo.bottom); | ||
distance.left = Math.abs(domInfo.left - scrollInfo.left); | ||
} else { | ||
//console.error('Dom is not in screen', { domInfo, scrollInfo }); | ||
return false; | ||
} | ||
distance.top = Math.abs(domInfo.top - scrollInfo.top); | ||
distance.right = Math.abs(domInfo.right - scrollInfo.right); | ||
distance.bottom = Math.abs(domInfo.bottom - scrollInfo.bottom); | ||
distance.left = Math.abs(domInfo.left - scrollInfo.left); | ||
var distanceFlip = (_distanceFlip = {}, _defineProperty(_distanceFlip, distance.top, 't'), _defineProperty(_distanceFlip, distance.right, 'r'), _defineProperty(_distanceFlip, distance.bottom, 'b'), _defineProperty(_distanceFlip, distance.left, 'l'), _distanceFlip); | ||
@@ -67,6 +60,33 @@ var maxDistance = Math.max(distance.top, distance.right, distance.bottom, distance.left); | ||
var lr = secondKey; | ||
return { domInfo: domInfo, locs: locs, scrollInfo: scrollInfo, tb: tb, lr: lr }; | ||
return { | ||
locs: locs, | ||
tb: tb, | ||
lr: lr | ||
}; | ||
}; | ||
var getWindowOffset = function getWindowOffset(dom) { | ||
if (!dom) { | ||
console.error('getWindowOffset not assign dom'); | ||
console.trace(); | ||
return false; | ||
} | ||
var scrollInfo = (0, _getScrollInfo2.default)(); | ||
var domInfo = (0, _isOnScreen2.default)((0, _getoffset2.default)(dom), scrollInfo); | ||
domInfo.isFixed = (0, _isFixed2.default)(dom); | ||
if (!domInfo.isFixed && !domInfo.isOnScreen) { | ||
console.warn('Dom is not in screen', { domInfo: domInfo, scrollInfo: scrollInfo }); | ||
return false; | ||
} | ||
var cookScrollInfo = _extends({}, scrollInfo); | ||
if (domInfo.isFixed) { | ||
cookScrollInfo.top = 0; | ||
cookScrollInfo.right = scrollInfo.scrollNodeWidth; | ||
cookScrollInfo.bottom = scrollInfo.scrollNodeHeight; | ||
cookScrollInfo.left = 0; | ||
} | ||
return _extends({ domInfo: domInfo, scrollInfo: scrollInfo }, calWindowOffset(domInfo, cookScrollInfo)); | ||
}; | ||
exports.default = getWindowOffset; | ||
module.exports = exports['default']; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.isOnScreen = exports.getPositionString = exports.alignUI = exports.default = undefined; | ||
exports.isFixed = exports.isOnScreen = exports.getPositionString = exports.alignUI = exports.default = undefined; | ||
@@ -36,2 +36,11 @@ var _alignUI = require('./alignUI'); | ||
var _isFixed = require('./isFixed'); | ||
Object.defineProperty(exports, 'isFixed', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_isFixed).default; | ||
} | ||
}); | ||
var _getWindowOffset = require('./getWindowOffset'); | ||
@@ -38,0 +47,0 @@ |
{ | ||
"name": "get-window-offset", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "A simple library to tell you where could get best space by a target to put your container.", | ||
@@ -13,9 +13,7 @@ "repository": "react-atomic/react-atomic-organism", | ||
"get-scroll-info": "*", | ||
"get-style": "*", | ||
"getoffset": "*" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.x", | ||
"babel-core": "^6.x", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-stage-0": "^6.5.0" | ||
"babel-cli": "^6.x" | ||
}, | ||
@@ -22,0 +20,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15802
1
13
385
4
5
+ Addedget-style@*
+ Addedget-style@0.2.0(transitive)