@bva/vue-sticky-directive
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "@bva/vue-sticky-directive", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Vue directive to enable sticky scrolling on navigation elements such as headers and sidebars.", | ||
@@ -24,3 +24,3 @@ "main": "vue-sticky-directive.js", | ||
"dependencies": { | ||
"@bva/stickie": "^0.1.1" | ||
"@bva/stickie": "^0.1.2" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
import Stickie from "@bva/stickie"; | ||
/** | ||
* Type verify the `newOpts` argument before merging it with `oldOpts`. | ||
*/ | ||
export const mergeOptions = (oldOpts, newOpts) => { | ||
if (typeof newOpts === "undefined" || typeof newOpts === "object") { | ||
return { ...oldOpts, ...newOpts }; | ||
} else { | ||
console.warn( | ||
"v-sticky binding must be an object, fallback to previous option set." | ||
); | ||
return oldOpts; | ||
} | ||
const DEFAULTS = { | ||
contained: false, | ||
classScope: "sticky", | ||
eventScope: "sticky", | ||
}; | ||
const Sticky = (options = {}) => { | ||
const DEFAULTS = options.DEFAULTS || { | ||
container: false, | ||
classScope: "sticky", | ||
eventScope: "sticky", | ||
}; | ||
return { | ||
inserted(el, binding, vnode) { | ||
const mergedOptions = mergeOptions(DEFAULTS, binding.value); | ||
vnode.context.$nextTick(() => { | ||
new Stickie(el, mergedOptions); | ||
new Stickie(el, { ...DEFAULTS, ...binding.value }); | ||
}); | ||
@@ -32,0 +15,0 @@ }, |
@@ -37,12 +37,2 @@ (function (global, factory) { | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -63,27 +53,13 @@ if (key in obj) { | ||
/** | ||
* Type verify the `newOpts` argument before merging it with `oldOpts`. | ||
*/ | ||
var mergeOptions = function mergeOptions(oldOpts, newOpts) { | ||
if (typeof newOpts === "undefined" || _typeof(newOpts) === "object") { | ||
return _objectSpread2(_objectSpread2({}, oldOpts), newOpts); | ||
} else { | ||
console.warn("v-sticky binding must be an object, fallback to previous option set."); | ||
return oldOpts; | ||
} | ||
var DEFAULTS = { | ||
contained: false, | ||
classScope: "sticky", | ||
eventScope: "sticky" | ||
}; | ||
var Sticky = function Sticky() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var DEFAULTS = options.DEFAULTS || { | ||
container: false, | ||
classScope: "sticky", | ||
eventScope: "sticky" | ||
}; | ||
return { | ||
inserted: function inserted(el, binding, vnode) { | ||
var mergedOptions = mergeOptions(DEFAULTS, binding.value); | ||
vnode.context.$nextTick(function () { | ||
new Stickie__default["default"](el, mergedOptions); | ||
new Stickie__default["default"](el, _objectSpread2(_objectSpread2({}, DEFAULTS), binding.value)); | ||
}); | ||
@@ -90,0 +66,0 @@ }, |
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
9060
146
Updated@bva/stickie@^0.1.2