Comparing version 0.2.0 to 0.2.1
@@ -1,6 +0,13 @@ | ||
# 0.2.0 next | ||
# 0.2.1 | ||
- add test case; | ||
- Added `throttle` and `debounce` | ||
- Change `space` to 2 | ||
# 0.2.0 | ||
- All changes to support es2015 | ||
- Added test case | ||
# 0.1.1 | ||
@@ -7,0 +14,0 @@ > 2017-03-31 |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = global.cancelAnimationFrame || global.webkitCancelAnimationFrame || global.mozCancelAnimationFrame || global.oCancelAnimationFrame || global.msCancelAnimationFrame || global.clearTimeout; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.oRequestAnimationFrame || global.msRequestAnimationFrame; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -21,8 +21,8 @@ | ||
var requestAnimationFrame = _nativeRequestAnimationFrame2.default && _nativeRequestAnimationFrame2.default.bind(global) || function (callback) { | ||
var currTime = Date.now(); | ||
var timeDelay = Math.max(0, 16 - (currTime - lastTime)); | ||
lastTime = currTime + timeDelay; | ||
return global.setTimeout(function () { | ||
callback(Date.now()); | ||
}, timeDelay); | ||
var currTime = Date.now(); | ||
var timeDelay = Math.max(0, 16 - (currTime - lastTime)); | ||
lastTime = currTime + timeDelay; | ||
return global.setTimeout(function () { | ||
callback(Date.now()); | ||
}, timeDelay); | ||
}; | ||
@@ -29,0 +29,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,29 +14,29 @@ | ||
exports.default = { | ||
/** | ||
* @return {bool} True if browser supports css animations. | ||
*/ | ||
hasCSSAnimations: function hasCSSAnimations() { | ||
return !!(0, _getVendorPrefixedName2.default)('animationName'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css animations. | ||
*/ | ||
hasCSSAnimations: function hasCSSAnimations() { | ||
return !!(0, _getVendorPrefixedName2.default)('animationName'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css transforms. | ||
*/ | ||
hasCSSTransforms: function hasCSSTransforms() { | ||
return !!(0, _getVendorPrefixedName2.default)('transform'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css transforms. | ||
*/ | ||
hasCSSTransforms: function hasCSSTransforms() { | ||
return !!(0, _getVendorPrefixedName2.default)('transform'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css 3d transforms. | ||
*/ | ||
hasCSS3DTransforms: function hasCSS3DTransforms() { | ||
return !!(0, _getVendorPrefixedName2.default)('perspective'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css 3d transforms. | ||
*/ | ||
hasCSS3DTransforms: function hasCSS3DTransforms() { | ||
return !!(0, _getVendorPrefixedName2.default)('perspective'); | ||
}, | ||
/** | ||
* @return {bool} True if browser supports css transitions. | ||
*/ | ||
hasCSSTransitions: function hasCSSTransitions() { | ||
return !!(0, _getVendorPrefixedName2.default)('transition'); | ||
} | ||
/** | ||
* @return {bool} True if browser supports css transitions. | ||
*/ | ||
hasCSSTransitions: function hasCSSTransitions() { | ||
return !!(0, _getVendorPrefixedName2.default)('transition'); | ||
} | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,10 +14,10 @@ | ||
exports.default = function (target, className) { | ||
if (className) { | ||
if (target.classList) { | ||
target.classList.add(className); | ||
} else if (!(0, _hasClass2.default)(className, target)) { | ||
target.className = target.className + ' ' + className; | ||
} | ||
if (className) { | ||
if (target.classList) { | ||
target.classList.add(className); | ||
} else if (!(0, _hasClass2.default)(className, target)) { | ||
target.className = target.className + ' ' + className; | ||
} | ||
return target; | ||
} | ||
return target; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (target, className) { | ||
if (target.classList) { | ||
return !!className && target.classList.contains(className); | ||
} | ||
return (" " + target.className + " ").indexOf(" " + className + " ") !== -1; | ||
if (target.classList) { | ||
return !!className && target.classList.contains(className); | ||
} | ||
return (" " + target.className + " ").indexOf(" " + className + " ") !== -1; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,11 +14,11 @@ | ||
exports.default = function (target, className) { | ||
if (className) { | ||
if (target.classList) { | ||
target.classList.remove(className); | ||
} else { | ||
target.className = target.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ') // multiple spaces to one | ||
.replace(/^\s*|\s*$/g, ''); // trim the ends | ||
} | ||
if (className) { | ||
if (target.classList) { | ||
target.classList.remove(className); | ||
} else { | ||
target.className = target.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ') // multiple spaces to one | ||
.replace(/^\s*|\s*$/g, ''); // trim the ends | ||
} | ||
return target; | ||
} | ||
return target; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -22,6 +22,6 @@ | ||
exports.default = function (target, className) { | ||
if ((0, _hasClass2.default)(target, className)) { | ||
return (0, _removeClass2.default)(target, className); | ||
} | ||
return (0, _addClass2.default)(target, className); | ||
if ((0, _hasClass2.default)(target, className)) { | ||
return (0, _removeClass2.default)(target, className); | ||
} | ||
return (0, _addClass2.default)(target, className); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -22,128 +22,128 @@ | ||
var DOMMouseMoveTracker = function () { | ||
/** | ||
* onMove is the callback that will be called on every mouse move. | ||
* onMoveEnd is called on mouse up when movement has ended. | ||
*/ | ||
function DOMMouseMoveTracker(onMove, onMoveEnd, domNode) { | ||
_classCallCheck(this, DOMMouseMoveTracker); | ||
/** | ||
* onMove is the callback that will be called on every mouse move. | ||
* onMoveEnd is called on mouse up when movement has ended. | ||
*/ | ||
function DOMMouseMoveTracker(onMove, onMoveEnd, domNode) { | ||
_classCallCheck(this, DOMMouseMoveTracker); | ||
this._isDragging = false; | ||
this._animationFrameID = null; | ||
this._domNode = domNode; | ||
this._onMove = onMove; | ||
this._onMoveEnd = onMoveEnd; | ||
this._onMouseMove = this._onMouseMove.bind(this); | ||
this._onMouseUp = this._onMouseUp.bind(this); | ||
this._didMouseMove = this._didMouseMove.bind(this); | ||
} | ||
this._isDragging = false; | ||
this._animationFrameID = null; | ||
this._domNode = domNode; | ||
this._onMove = onMove; | ||
this._onMoveEnd = onMoveEnd; | ||
this._onMouseMove = this._onMouseMove.bind(this); | ||
this._onMouseUp = this._onMouseUp.bind(this); | ||
this._didMouseMove = this._didMouseMove.bind(this); | ||
} | ||
/** | ||
* This is to set up the listeners for listening to mouse move | ||
* and mouse up signaling the movement has ended. Please note that these | ||
* listeners are added at the document.body level. It takes in an event | ||
* in order to grab inital state. | ||
*/ | ||
/** | ||
* This is to set up the listeners for listening to mouse move | ||
* and mouse up signaling the movement has ended. Please note that these | ||
* listeners are added at the document.body level. It takes in an event | ||
* in order to grab inital state. | ||
*/ | ||
DOMMouseMoveTracker.prototype.captureMouseMoves = function captureMouseMoves(event) { | ||
DOMMouseMoveTracker.prototype.captureMouseMoves = function captureMouseMoves(event) { | ||
if (!this._eventMoveToken && !this._eventUpToken) { | ||
this._eventMoveToken = (0, _events.on)(this._domNode, 'mousemove', this._onMouseMove); | ||
this._eventUpToken = (0, _events.on)(this._domNode, 'mouseup', this._onMouseUp); | ||
} | ||
if (!this._eventMoveToken && !this._eventUpToken) { | ||
this._eventMoveToken = (0, _events.on)(this._domNode, 'mousemove', this._onMouseMove); | ||
this._eventUpToken = (0, _events.on)(this._domNode, 'mouseup', this._onMouseUp); | ||
} | ||
if (!this._isDragging) { | ||
this._deltaX = 0; | ||
this._deltaY = 0; | ||
this._isDragging = true; | ||
this._x = event.clientX; | ||
this._y = event.clientY; | ||
} | ||
if (!this._isDragging) { | ||
this._deltaX = 0; | ||
this._deltaY = 0; | ||
this._isDragging = true; | ||
this._x = event.clientX; | ||
this._y = event.clientY; | ||
} | ||
event.preventDefault(); | ||
}; | ||
event.preventDefault(); | ||
}; | ||
/** | ||
* These releases all of the listeners on document.body. | ||
*/ | ||
/** | ||
* These releases all of the listeners on document.body. | ||
*/ | ||
DOMMouseMoveTracker.prototype.releaseMouseMoves = function releaseMouseMoves() { | ||
DOMMouseMoveTracker.prototype.releaseMouseMoves = function releaseMouseMoves() { | ||
if (this._eventMoveToken && this._eventUpToken) { | ||
if (this._eventMoveToken && this._eventUpToken) { | ||
this._eventMoveToken.off(); | ||
this._eventMoveToken = null; | ||
this._eventUpToken.off(); | ||
this._eventUpToken = null; | ||
} | ||
this._eventMoveToken.off(); | ||
this._eventMoveToken = null; | ||
this._eventUpToken.off(); | ||
this._eventUpToken = null; | ||
} | ||
if (this._animationFrameID !== null) { | ||
(0, _cancelAnimationFramePolyfill2.default)(this._animationFrameID); | ||
this._animationFrameID = null; | ||
} | ||
if (this._animationFrameID !== null) { | ||
(0, _cancelAnimationFramePolyfill2.default)(this._animationFrameID); | ||
this._animationFrameID = null; | ||
} | ||
if (this._isDragging) { | ||
this._isDragging = false; | ||
this._x = null; | ||
this._y = null; | ||
} | ||
}; | ||
if (this._isDragging) { | ||
this._isDragging = false; | ||
this._x = null; | ||
this._y = null; | ||
} | ||
}; | ||
/** | ||
* Returns whether or not if the mouse movement is being tracked. | ||
*/ | ||
/** | ||
* Returns whether or not if the mouse movement is being tracked. | ||
*/ | ||
DOMMouseMoveTracker.prototype.isDragging = function isDragging() /*boolean*/{ | ||
return this._isDragging; | ||
}; | ||
DOMMouseMoveTracker.prototype.isDragging = function isDragging() /*boolean*/{ | ||
return this._isDragging; | ||
}; | ||
/** | ||
* Calls onMove passed into constructor and updates internal state. | ||
*/ | ||
/** | ||
* Calls onMove passed into constructor and updates internal state. | ||
*/ | ||
DOMMouseMoveTracker.prototype._onMouseMove = function _onMouseMove( /*object*/event) { | ||
DOMMouseMoveTracker.prototype._onMouseMove = function _onMouseMove( /*object*/event) { | ||
var x = event.clientX; | ||
var y = event.clientY; | ||
var x = event.clientX; | ||
var y = event.clientY; | ||
this._deltaX += x - this._x; | ||
this._deltaY += y - this._y; | ||
this._deltaX += x - this._x; | ||
this._deltaY += y - this._y; | ||
if (this._animationFrameID === null) { | ||
// The mouse may move faster then the animation frame does. | ||
// Use `requestAnimationFramePolyfill` to avoid over-updating. | ||
this._animationFrameID = (0, _requestAnimationFramePolyfill2.default)(this._didMouseMove); | ||
} | ||
if (this._animationFrameID === null) { | ||
// The mouse may move faster then the animation frame does. | ||
// Use `requestAnimationFramePolyfill` to avoid over-updating. | ||
this._animationFrameID = (0, _requestAnimationFramePolyfill2.default)(this._didMouseMove); | ||
} | ||
this._x = x; | ||
this._y = y; | ||
this._moveEvent = event; | ||
event.preventDefault(); | ||
}; | ||
this._x = x; | ||
this._y = y; | ||
this._moveEvent = event; | ||
event.preventDefault(); | ||
}; | ||
DOMMouseMoveTracker.prototype._didMouseMove = function _didMouseMove() { | ||
this._animationFrameID = null; | ||
this._onMove(this._deltaX, this._deltaY, this._moveEvent); | ||
this._deltaX = 0; | ||
this._deltaY = 0; | ||
}; | ||
/** | ||
* Calls onMoveEnd passed into constructor and updates internal state. | ||
*/ | ||
DOMMouseMoveTracker.prototype._didMouseMove = function _didMouseMove() { | ||
this._animationFrameID = null; | ||
this._onMove(this._deltaX, this._deltaY, this._moveEvent); | ||
this._deltaX = 0; | ||
this._deltaY = 0; | ||
}; | ||
/** | ||
* Calls onMoveEnd passed into constructor and updates internal state. | ||
*/ | ||
DOMMouseMoveTracker.prototype._onMouseUp = function _onMouseUp() { | ||
DOMMouseMoveTracker.prototype._onMouseUp = function _onMouseUp() { | ||
if (this._animationFrameID) { | ||
this._didMouseMove(); | ||
} | ||
this._onMoveEnd(); | ||
}; | ||
if (this._animationFrameID) { | ||
this._didMouseMove(); | ||
} | ||
this._onMoveEnd(); | ||
}; | ||
return DOMMouseMoveTracker; | ||
return DOMMouseMoveTracker; | ||
}(); | ||
exports.default = DOMMouseMoveTracker; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -20,10 +20,10 @@ var bind = window.addEventListener ? 'addEventListener' : 'attachEvent'; | ||
exports.default = function (target, eventName, listener) { | ||
var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
target[bind](eventPrefix + eventName, listener, capture); | ||
return { | ||
off: function off() { | ||
target[unbind](eventPrefix + eventName, listener, capture); | ||
} | ||
}; | ||
target[bind](eventPrefix + eventName, listener, capture); | ||
return { | ||
off: function off() { | ||
target[unbind](eventPrefix + eventName, listener, capture); | ||
} | ||
}; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (listener) { | ||
var useFocusin = !document.addEventListener; | ||
var off = void 0; | ||
var useFocusin = !document.addEventListener; | ||
var off = void 0; | ||
if (useFocusin) { | ||
document.attachEvent('onfocusin', listener); | ||
off = function off() { | ||
return document.detachEvent('onfocusin', listener); | ||
}; | ||
} else { | ||
document.addEventListener('focus', listener, true); | ||
off = function off() { | ||
return document.removeEventListener('focus', listener, true); | ||
}; | ||
} | ||
if (useFocusin) { | ||
document.attachEvent('onfocusin', listener); | ||
off = function off() { | ||
return document.detachEvent('onfocusin', listener); | ||
}; | ||
} else { | ||
document.addEventListener('focus', listener, true); | ||
off = function off() { | ||
return document.removeEventListener('focus', listener, true); | ||
}; | ||
} | ||
return { | ||
off: off | ||
}; | ||
return { | ||
off: off | ||
}; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -17,9 +17,9 @@ | ||
function getWithPrefix(name) { | ||
for (var i = 0; i < prefixes.length; i++) { | ||
var prefixedName = prefixes[i] + name; | ||
if (prefixedName in testStyle) { | ||
return prefixedName; | ||
} | ||
for (var i = 0; i < prefixes.length; i++) { | ||
var prefixedName = prefixes[i] + name; | ||
if (prefixedName in testStyle) { | ||
return prefixedName; | ||
} | ||
return null; | ||
} | ||
return null; | ||
} | ||
@@ -33,13 +33,13 @@ | ||
function getVendorPrefixedName(property) { | ||
var name = (0, _stringFormatter.camelize)(property); | ||
if (memoized[name] === undefined) { | ||
var capitalizedName = name.charAt(0).toUpperCase() + name.slice(1); | ||
if (prefixRegex.test(capitalizedName)) { | ||
throw new Error('getVendorPrefixedName must only be called with unprefixed' + 'CSS property names. It was called with %s', property); | ||
} | ||
memoized[name] = name in testStyle ? name : getWithPrefix(capitalizedName); | ||
var name = (0, _stringFormatter.camelize)(property); | ||
if (memoized[name] === undefined) { | ||
var capitalizedName = name.charAt(0).toUpperCase() + name.slice(1); | ||
if (prefixRegex.test(capitalizedName)) { | ||
throw new Error('getVendorPrefixedName must only be called with unprefixed' + 'CSS property names. It was called with %s', property); | ||
} | ||
return memoized[name]; | ||
memoized[name] = name in testStyle ? name : getWithPrefix(capitalizedName); | ||
} | ||
return memoized[name]; | ||
} | ||
exports.default = getVendorPrefixedName; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function () { | ||
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; | ||
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; | ||
return doc.activeElement; | ||
return doc.activeElement; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = !!(typeof window !== 'undefined' && window.document && window.document.createElement); |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,18 +14,24 @@ | ||
exports.default = function () { | ||
var root = _canUseDOM2.default && document.documentElement; | ||
var root = _canUseDOM2.default && document.documentElement; | ||
return root && root.contains ? function (context, node) { | ||
return context.contains(node); | ||
} : root && root.compareDocumentPosition ? function (context, node) { | ||
return context === node || !!(context.compareDocumentPosition(node) & 16); | ||
} : function (context, node) { | ||
if (node) { | ||
do { | ||
if (node === context) { | ||
return true; | ||
} | ||
} while (node = node.parentNode); | ||
} | ||
return false; | ||
if (root && root.contains) { | ||
return function (context, node) { | ||
return context.contains(node); | ||
}; | ||
} else if (root && root.compareDocumentPosition) { | ||
return function (context, node) { | ||
return context === node || !!(context.compareDocumentPosition(node) & 16); | ||
}; | ||
} else { | ||
return function (context, node) { | ||
if (node) { | ||
do { | ||
if (node === context) { | ||
return true; | ||
} | ||
} while (node = node.parentNode); | ||
} | ||
return false; | ||
}; | ||
} | ||
}(); |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (container, defaultContainer) { | ||
container = typeof container === 'function' ? container() : container; | ||
return container || defaultContainer; | ||
container = typeof container === 'function' ? container() : container; | ||
return container || defaultContainer; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -18,4 +18,4 @@ | ||
exports.default = function (node, client) { | ||
var win = (0, _getWindow2.default)(node); | ||
return win ? win.innerHeight : client ? node.clientHeight : (0, _getOffset2.default)(node).height; | ||
var win = (0, _getWindow2.default)(node); | ||
return win ? win.innerHeight : client ? node.clientHeight : (0, _getOffset2.default)(node).height; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -22,36 +22,36 @@ | ||
exports.default = function (node) { | ||
var doc = (0, _ownerDocument2.default)(node); | ||
var win = (0, _getWindow2.default)(doc); | ||
var docElem = doc && doc.documentElement; | ||
var box = { | ||
top: 0, | ||
left: 0, | ||
height: 0, | ||
width: 0 | ||
}; | ||
var doc = (0, _ownerDocument2.default)(node); | ||
var win = (0, _getWindow2.default)(doc); | ||
var docElem = doc && doc.documentElement; | ||
var box = { | ||
top: 0, | ||
left: 0, | ||
height: 0, | ||
width: 0 | ||
}; | ||
if (!doc) { | ||
return; | ||
} | ||
if (!doc) { | ||
return; | ||
} | ||
// Make sure it's not a disconnected DOM node | ||
if (!(0, _contains2.default)(docElem, node)) { | ||
return box; | ||
} | ||
// Make sure it's not a disconnected DOM node | ||
if (!(0, _contains2.default)(docElem, node)) { | ||
return box; | ||
} | ||
if (node.getBoundingClientRect !== undefined) { | ||
box = node.getBoundingClientRect(); | ||
} | ||
if (node.getBoundingClientRect !== undefined) { | ||
box = node.getBoundingClientRect(); | ||
} | ||
if (box.width || box.height) { | ||
if (box.width || box.height) { | ||
box = { | ||
top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), | ||
left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), | ||
width: (box.width === null ? node.offsetWidth : box.width) || 0, | ||
height: (box.height === null ? node.offsetHeight : box.height) || 0 | ||
}; | ||
} | ||
box = { | ||
top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), | ||
left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), | ||
width: (box.width === null ? node.offsetWidth : box.width) || 0, | ||
height: (box.height === null ? node.offsetHeight : box.height) || 0 | ||
}; | ||
} | ||
return box; | ||
return box; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -20,10 +20,10 @@ | ||
exports.default = function (node) { | ||
var doc = (0, _ownerDocument2.default)(node), | ||
offsetParent = node && node.offsetParent; | ||
var doc = (0, _ownerDocument2.default)(node), | ||
offsetParent = node && node.offsetParent; | ||
while (offsetParent && (0, _nodeName2.default)(node) !== 'html' && (0, _style.getStyle)(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
while (offsetParent && (0, _nodeName2.default)(node) !== 'html' && (0, _style.getStyle)(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || doc.documentElement; | ||
return offsetParent || doc.documentElement; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -34,30 +34,30 @@ | ||
exports.default = function (node, offsetParent) { | ||
var parentOffset = { | ||
top: 0, | ||
left: 0 | ||
}; | ||
var offset = void 0; | ||
var parentOffset = { | ||
top: 0, | ||
left: 0 | ||
}; | ||
var offset = void 0; | ||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, | ||
// because it is its only offset parent | ||
if ((0, _style.getStyle)(node, 'position') === 'fixed') { | ||
offset = node.getBoundingClientRect(); | ||
} else { | ||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, | ||
// because it is its only offset parent | ||
if ((0, _style.getStyle)(node, 'position') === 'fixed') { | ||
offset = node.getBoundingClientRect(); | ||
} else { | ||
offsetParent = offsetParent || (0, _getOffsetParent2.default)(node); | ||
offset = (0, _getOffset2.default)(node); | ||
offsetParent = offsetParent || (0, _getOffsetParent2.default)(node); | ||
offset = (0, _getOffset2.default)(node); | ||
if ((0, _nodeName2.default)(offsetParent) !== 'html') { | ||
parentOffset = (0, _getOffset2.default)(offsetParent); | ||
} | ||
parentOffset.top += parseInt((0, _style.getStyle)(offsetParent, 'borderTopWidth'), 10) - (0, _scrollTop2.default)(offsetParent) || 0; | ||
parentOffset.left += parseInt((0, _style.getStyle)(offsetParent, 'borderLeftWidth'), 10) - (0, _scrollLeft2.default)(offsetParent) || 0; | ||
if ((0, _nodeName2.default)(offsetParent) !== 'html') { | ||
parentOffset = (0, _getOffset2.default)(offsetParent); | ||
} | ||
// Subtract parent offsets and node margins | ||
return _extends({}, offset, { | ||
top: offset.top - parentOffset.top - (parseInt((0, _style.getStyle)(node, 'marginTop'), 10) || 0), | ||
left: offset.left - parentOffset.left - (parseInt((0, _style.getStyle)(node, 'marginLeft'), 10) || 0) | ||
}); | ||
parentOffset.top += parseInt((0, _style.getStyle)(offsetParent, 'borderTopWidth'), 10) - (0, _scrollTop2.default)(offsetParent) || 0; | ||
parentOffset.left += parseInt((0, _style.getStyle)(offsetParent, 'borderLeftWidth'), 10) - (0, _scrollLeft2.default)(offsetParent) || 0; | ||
} | ||
// Subtract parent offsets and node margins | ||
return _extends({}, offset, { | ||
top: offset.top - parentOffset.top - (parseInt((0, _style.getStyle)(node, 'marginTop'), 10) || 0), | ||
left: offset.left - parentOffset.left - (parseInt((0, _style.getStyle)(node, 'marginLeft'), 10) || 0) | ||
}); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,20 +14,20 @@ | ||
exports.default = function (recalc) { | ||
var size = void 0; | ||
if (!size || recalc) { | ||
if (_canUseDOM2.default) { | ||
var scrollDiv = document.createElement('div'); | ||
var size = void 0; | ||
if (!size || recalc) { | ||
if (_canUseDOM2.default) { | ||
var scrollDiv = document.createElement('div'); | ||
scrollDiv.style.position = 'absolute'; | ||
scrollDiv.style.top = '-9999px'; | ||
scrollDiv.style.width = '50px'; | ||
scrollDiv.style.height = '50px'; | ||
scrollDiv.style.overflow = 'scroll'; | ||
scrollDiv.style.position = 'absolute'; | ||
scrollDiv.style.top = '-9999px'; | ||
scrollDiv.style.width = '50px'; | ||
scrollDiv.style.height = '50px'; | ||
scrollDiv.style.overflow = 'scroll'; | ||
document.body.appendChild(scrollDiv); | ||
size = scrollDiv.offsetWidth - scrollDiv.clientWidth; | ||
document.body.removeChild(scrollDiv); | ||
} | ||
document.body.appendChild(scrollDiv); | ||
size = scrollDiv.offsetWidth - scrollDiv.clientWidth; | ||
document.body.removeChild(scrollDiv); | ||
} | ||
} | ||
return size; | ||
return size; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -18,4 +18,4 @@ | ||
exports.default = function (node, client) { | ||
var win = (0, _getWindow2.default)(node); | ||
return win ? win.innerWidth : client ? node.clientWidth : (0, _getOffset2.default)(node).width; | ||
var win = (0, _getWindow2.default)(node); | ||
return win ? win.innerWidth : client ? node.clientWidth : (0, _getOffset2.default)(node).width; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (node) { | ||
return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; | ||
return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -18,19 +18,19 @@ | ||
exports.default = function (container) { | ||
var win = (0, _getWindow2.default)(container); | ||
var isBody = container && container.tagName.toLowerCase() === 'body'; | ||
var win = (0, _getWindow2.default)(container); | ||
var isBody = container && container.tagName.toLowerCase() === 'body'; | ||
function bodyIsOverflowing(node) { | ||
var doc = (0, _ownerDocument2.default)(node); | ||
var win = (0, _getWindow2.default)(doc); | ||
var fullWidth = win.innerWidth; | ||
function bodyIsOverflowing(node) { | ||
var doc = (0, _ownerDocument2.default)(node); | ||
var win = (0, _getWindow2.default)(doc); | ||
var fullWidth = win.innerWidth; | ||
// Support: ie8, no innerWidth | ||
if (!fullWidth) { | ||
var documentElementRect = doc.documentElement.getBoundingClientRect(); | ||
fullWidth = documentElementRect.right - Math.abs(documentElementRect.left); | ||
} | ||
return doc.body.clientWidth < fullWidth; | ||
// Support: ie8, no innerWidth | ||
if (!fullWidth) { | ||
var documentElementRect = doc.documentElement.getBoundingClientRect(); | ||
fullWidth = documentElementRect.right - Math.abs(documentElementRect.left); | ||
} | ||
return doc.body.clientWidth < fullWidth; | ||
} | ||
return win || isBody ? bodyIsOverflowing(container) : container.scrollHeight > container.clientHeight; | ||
return win || isBody ? bodyIsOverflowing(container) : container.scrollHeight > container.clientHeight; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (node) { | ||
return node.nodeName && node.nodeName.toLowerCase(); | ||
return node.nodeName && node.nodeName.toLowerCase(); | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = function (node) { | ||
return node && node.ownerDocument || document; | ||
return node && node.ownerDocument || document; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,4 +14,4 @@ | ||
exports.default = function (componentOrElement) { | ||
var doc = (0, _ownerDocument2.default)(componentOrElement); | ||
return doc && doc.defaultView || doc.parentWindow; | ||
var doc = (0, _ownerDocument2.default)(componentOrElement); | ||
return doc && doc.defaultView || doc.parentWindow; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -15,11 +15,11 @@ | ||
var win = (0, _getWindow2.default)(node); | ||
var left = win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : node.scrollLeft; | ||
var top = win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : 0; | ||
var win = (0, _getWindow2.default)(node); | ||
var left = win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : node.scrollLeft; | ||
var top = win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : 0; | ||
if (val === undefined) { | ||
return left; | ||
} | ||
if (val === undefined) { | ||
return left; | ||
} | ||
win ? win.scrollTo(val, top) : node.scrollLeft = val; | ||
win ? win.scrollTo(val, top) : node.scrollLeft = val; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -14,10 +14,10 @@ | ||
exports.default = function (node, val) { | ||
var win = (0, _getWindow2.default)(node); | ||
var top = win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop; | ||
var left = win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : 0; | ||
var win = (0, _getWindow2.default)(node); | ||
var top = win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop; | ||
var left = win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : 0; | ||
if (val === undefined) { | ||
return top; | ||
} | ||
win ? win.scrollTo(left, val) : node.scrollTop = val; | ||
if (val === undefined) { | ||
return top; | ||
} | ||
win ? win.scrollTo(left, val) : node.scrollTop = val; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -18,19 +18,19 @@ | ||
exports.default = function (node, property, value) { | ||
var css = ''; | ||
var props = property; | ||
var css = ''; | ||
var props = property; | ||
if (typeof property === 'string') { | ||
if (value === undefined) { | ||
new Error('value is undefined'); | ||
} | ||
(props = {})[property] = value; | ||
if (typeof property === 'string') { | ||
if (value === undefined) { | ||
new Error('value is undefined'); | ||
} | ||
(props = {})[property] = value; | ||
} | ||
for (var key in props) { | ||
if (Object.prototype.hasOwnProperty.call(props, key)) { | ||
!props[key] && props[key] !== 0 ? (0, _removeStyle2.default)(node, (0, _hyphenateStyleName2.default)(key)) : css += (0, _hyphenateStyleName2.default)(key) + ':' + props[key] + ';'; | ||
} | ||
for (var key in props) { | ||
if (Object.prototype.hasOwnProperty.call(props, key)) { | ||
!props[key] && props[key] !== 0 ? (0, _removeStyle2.default)(node, (0, _hyphenateStyleName2.default)(key)) : css += (0, _hyphenateStyleName2.default)(key) + ':' + props[key] + ';'; | ||
} | ||
} | ||
node.style.cssText += ';' + css; | ||
node.style.cssText += ';' + css; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -12,3 +12,3 @@ | ||
exports.default = function (string) { | ||
return (0, _stringFormatter.camelize)(string.replace(msPattern, 'ms-')); | ||
return (0, _stringFormatter.camelize)(string.replace(msPattern, 'ms-')); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -11,55 +11,55 @@ | ||
exports.default = function (node) { | ||
if (!node) { | ||
throw new TypeError('No Element passed to `getComputedStyle()`'); | ||
} | ||
if (!node) { | ||
throw new TypeError('No Element passed to `getComputedStyle()`'); | ||
} | ||
var doc = node.ownerDocument; | ||
var doc = node.ownerDocument; | ||
if ('defaultView' in doc) { | ||
if (doc.defaultView.opener) { | ||
return node.ownerDocument.defaultView.getComputedStyle(node, null); | ||
} | ||
return window.getComputedStyle(node, null); | ||
if ('defaultView' in doc) { | ||
if (doc.defaultView.opener) { | ||
return node.ownerDocument.defaultView.getComputedStyle(node, null); | ||
} | ||
return { | ||
getPropertyValue: function getPropertyValue(prop) { | ||
return window.getComputedStyle(node, null); | ||
} | ||
return { | ||
getPropertyValue: function getPropertyValue(prop) { | ||
var style = node.style; | ||
var style = node.style; | ||
prop = camelize(prop); | ||
prop = camelize(prop); | ||
if (prop === 'float') { | ||
prop = 'styleFloat'; | ||
} | ||
if (prop === 'float') { | ||
prop = 'styleFloat'; | ||
} | ||
var current = node.currentStyle[prop] || null; | ||
var current = node.currentStyle[prop] || null; | ||
if (current === null && style && style[prop]) { | ||
current = style[prop]; | ||
} | ||
if (current === null && style && style[prop]) { | ||
current = style[prop]; | ||
} | ||
if (rnumnonpx.test(current) && !rposition.test(prop)) { | ||
// Remember the original values | ||
var left = style.left; | ||
var runStyle = node.runtimeStyle; | ||
var rsLeft = runStyle && runStyle.left; | ||
if (rnumnonpx.test(current) && !rposition.test(prop)) { | ||
// Remember the original values | ||
var left = style.left; | ||
var runStyle = node.runtimeStyle; | ||
var rsLeft = runStyle && runStyle.left; | ||
// Put in the new values to get a computed value out | ||
if (rsLeft) { | ||
runStyle.left = node.currentStyle.left; | ||
} | ||
// Put in the new values to get a computed value out | ||
if (rsLeft) { | ||
runStyle.left = node.currentStyle.left; | ||
} | ||
style.left = prop === 'fontSize' ? '1em' : current; | ||
current = style.pixelLeft + 'px'; | ||
style.left = prop === 'fontSize' ? '1em' : current; | ||
current = style.pixelLeft + 'px'; | ||
// Revert the changed values | ||
style.left = left; | ||
if (rsLeft) { | ||
runStyle.left = rsLeft; | ||
} | ||
} | ||
// Revert the changed values | ||
style.left = left; | ||
if (rsLeft) { | ||
runStyle.left = rsLeft; | ||
} | ||
} | ||
return current; | ||
} | ||
}; | ||
return current; | ||
} | ||
}; | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -23,7 +23,7 @@ | ||
if (property) { | ||
return node.style[(0, _camelizeStyleName2.default)(property)] || (0, _getComputedStyle2.default)(node).getPropertyValue((0, _hyphenateStyleName2.default)(property)); | ||
} | ||
if (property) { | ||
return node.style[(0, _camelizeStyleName2.default)(property)] || (0, _getComputedStyle2.default)(node).getPropertyValue((0, _hyphenateStyleName2.default)(property)); | ||
} | ||
return node.style || (0, _getComputedStyle2.default)(node); | ||
return node.style || (0, _getComputedStyle2.default)(node); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -12,3 +12,3 @@ | ||
exports.default = function (string) { | ||
return (0, _stringFormatter.hyphenate)(string).replace(msPattern, '-ms-'); | ||
return (0, _stringFormatter.hyphenate)(string).replace(msPattern, '-ms-'); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
function removeStyle(node, key) { | ||
return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); | ||
return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); | ||
} | ||
@@ -18,9 +18,9 @@ | ||
if (typeof key === 'string') { | ||
return removeStyle(node, keys); | ||
} else if (Object.prototype.toString.call(keys) === '[object Array]') { | ||
keys.forEach(function (key) { | ||
return removeStyle(node, key); | ||
}); | ||
} | ||
if (typeof key === 'string') { | ||
return removeStyle(node, keys); | ||
} else if (Object.prototype.toString.call(keys) === '[object Array]') { | ||
keys.forEach(function (key) { | ||
return removeStyle(node, key); | ||
}); | ||
} | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -19,53 +19,53 @@ | ||
if (_query.canUseDOM) { | ||
transition = getTransitionProperties(); | ||
transition = getTransitionProperties(); | ||
transform = transition.prefix + transform; | ||
transform = transition.prefix + transform; | ||
transitionProperty = transition.prefix + 'transition-property'; | ||
transitionDuration = transition.prefix + 'transition-duration'; | ||
transitionDelay = transition.prefix + 'transition-delay'; | ||
transitionTiming = transition.prefix + 'transition-timing-function'; | ||
backfaceVisibility = transition.prefix + 'backface-visibility'; | ||
transitionProperty = transition.prefix + 'transition-property'; | ||
transitionDuration = transition.prefix + 'transition-duration'; | ||
transitionDelay = transition.prefix + 'transition-delay'; | ||
transitionTiming = transition.prefix + 'transition-timing-function'; | ||
backfaceVisibility = transition.prefix + 'backface-visibility'; | ||
} | ||
function getTransitionProperties() { | ||
var endEvent = void 0, | ||
prefix = '', | ||
transitions = { | ||
O: 'otransitionend', | ||
Moz: 'transitionend', | ||
Webkit: 'webkitTransitionEnd', | ||
ms: 'MSTransitionEnd' | ||
}; | ||
var endEvent = void 0, | ||
prefix = '', | ||
transitions = { | ||
O: 'otransitionend', | ||
Moz: 'transitionend', | ||
Webkit: 'webkitTransitionEnd', | ||
ms: 'MSTransitionEnd' | ||
}; | ||
var element = document.createElement('div'); | ||
var element = document.createElement('div'); | ||
for (var vendor in transitions) { | ||
if (has.call(transitions, vendor)) { | ||
if (element.style[vendor + 'TransitionProperty'] !== undefined) { | ||
prefix = '-' + vendor.toLowerCase() + '-'; | ||
endEvent = transitions[vendor]; | ||
break; | ||
} | ||
} | ||
for (var vendor in transitions) { | ||
if (has.call(transitions, vendor)) { | ||
if (element.style[vendor + 'TransitionProperty'] !== undefined) { | ||
prefix = '-' + vendor.toLowerCase() + '-'; | ||
endEvent = transitions[vendor]; | ||
break; | ||
} | ||
} | ||
} | ||
if (!endEvent && element.style.transitionProperty !== undefined) { | ||
endEvent = 'transitionend'; | ||
} | ||
if (!endEvent && element.style.transitionProperty !== undefined) { | ||
endEvent = 'transitionend'; | ||
} | ||
return { | ||
end: endEvent, | ||
prefix: prefix | ||
}; | ||
return { | ||
end: endEvent, | ||
prefix: prefix | ||
}; | ||
} | ||
exports.default = { | ||
backfaceVisibility: backfaceVisibility, | ||
transform: transform, | ||
end: transition.end, | ||
property: transitionProperty, | ||
timing: transitionTiming, | ||
delay: transitionDelay, | ||
duration: transitionDuration | ||
backfaceVisibility: backfaceVisibility, | ||
transform: transform, | ||
end: transition.end, | ||
property: transitionProperty, | ||
timing: transitionTiming, | ||
delay: transitionDelay, | ||
duration: transitionDuration | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -17,3 +17,3 @@ exports.underscore = underscore; | ||
function underscore(string) { | ||
return string.replace(/([A-Z])/g, '_$1').toLowerCase(); | ||
return string.replace(/([A-Z])/g, '_$1').toLowerCase(); | ||
} | ||
@@ -27,5 +27,5 @@ | ||
function camelize(string) { | ||
return string.replace(/\-(\w)/g, function (char) { | ||
return char.slice(1).toUpperCase(); | ||
}); | ||
return string.replace(/\-(\w)/g, function (char) { | ||
return char.slice(1).toUpperCase(); | ||
}); | ||
} | ||
@@ -39,3 +39,3 @@ | ||
function hyphenate(string) { | ||
return string.replace(/([A-Z])/g, '-$1').toLowerCase(); | ||
return string.replace(/([A-Z])/g, '-$1').toLowerCase(); | ||
} | ||
@@ -49,9 +49,9 @@ | ||
function merge(pattern) { | ||
var pointer = 0, | ||
i; | ||
for (i = 1; i < arguments.length; i++) { | ||
pattern = pattern.split('{' + pointer + '}').join(arguments[i]); | ||
pointer++; | ||
} | ||
return pattern; | ||
var pointer = 0, | ||
i; | ||
for (i = 1; i < arguments.length; i++) { | ||
pattern = pattern.split('{' + pointer + '}').join(arguments[i]); | ||
pointer++; | ||
} | ||
return pattern; | ||
} |
{ | ||
"name": "dom-lib", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "DOM helper library", | ||
@@ -11,3 +11,2 @@ "main": "lib/index.js", | ||
"build": "rm -rf lib && babel src --out-dir lib", | ||
"dev": "webpack --progress -colors --watch", | ||
"tdd": "karma start", | ||
@@ -62,5 +61,4 @@ "lint": "eslint src *.js", | ||
"style-loader": "^0.13.1", | ||
"webpack": "^2.3.2", | ||
"webpack-dev-server": "^2.4.2" | ||
"webpack": "^2.3.2" | ||
} | ||
} |
@@ -68,2 +68,3 @@ # dom-lib [![Travis][build-badge]][build] [![npm][npm-badge]][npm] | ||
Object ownerWindow(Element componentOrElement) | ||
Boolean contains(Element context, Element node) | ||
void scrollLeft(Element node, Number val) | ||
@@ -70,0 +71,0 @@ void scrollTop(Element node, Number val) |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47371
35
50
1110
80
0