jquery-sticky-table-header
Advanced tools
Comparing version 0.2.2 to 1.0.0
/*! | ||
* jquery-sticky-table-header | ||
* 0.2.2 | ||
* 1.0.0 | ||
* Requires jQuery 1.12.0+ | ||
@@ -13,3 +13,3 @@ * https://github.com/simonsmith/jquery.stickyTableHeader/ | ||
} | ||
}(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { | ||
}("undefined" != typeof self ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__) { | ||
return function(modules) { | ||
@@ -149,3 +149,5 @@ function __webpack_require__(moduleId) { | ||
}; | ||
$win.on("scroll." + PLUGIN_NAME, throttle(handler, scrollThrottle)); | ||
$win.on("scroll." + PLUGIN_NAME, throttle(handler, scrollThrottle, { | ||
leading: !0 | ||
})); | ||
} | ||
@@ -183,14 +185,98 @@ }, { | ||
}, function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function throttle(callback, wait) { | ||
var context = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : this, timeout = null, callbackArgs = null, later = function() { | ||
callback.apply(context, callbackArgs), timeout = null; | ||
(function(global) { | ||
function debounce(func, wait, options) { | ||
function invokeFunc(time) { | ||
var args = lastArgs, thisArg = lastThis; | ||
return lastArgs = lastThis = void 0, lastInvokeTime = time, result = func.apply(thisArg, args); | ||
} | ||
function leadingEdge(time) { | ||
return lastInvokeTime = time, timerId = setTimeout(timerExpired, wait), leading ? invokeFunc(time) : result; | ||
} | ||
function remainingWait(time) { | ||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result = wait - timeSinceLastCall; | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
function shouldInvoke(time) { | ||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime; | ||
return void 0 === lastCallTime || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; | ||
} | ||
function timerExpired() { | ||
var time = now(); | ||
if (shouldInvoke(time)) return trailingEdge(time); | ||
timerId = setTimeout(timerExpired, remainingWait(time)); | ||
} | ||
function trailingEdge(time) { | ||
return timerId = void 0, trailing && lastArgs ? invokeFunc(time) : (lastArgs = lastThis = void 0, | ||
result); | ||
} | ||
function cancel() { | ||
void 0 !== timerId && clearTimeout(timerId), lastInvokeTime = 0, lastArgs = lastCallTime = lastThis = timerId = void 0; | ||
} | ||
function flush() { | ||
return void 0 === timerId ? result : trailingEdge(now()); | ||
} | ||
function debounced() { | ||
var time = now(), isInvoking = shouldInvoke(time); | ||
if (lastArgs = arguments, lastThis = this, lastCallTime = time, isInvoking) { | ||
if (void 0 === timerId) return leadingEdge(lastCallTime); | ||
if (maxing) return timerId = setTimeout(timerExpired, wait), invokeFunc(lastCallTime); | ||
} | ||
return void 0 === timerId && (timerId = setTimeout(timerExpired, wait)), result; | ||
} | ||
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = !1, maxing = !1, trailing = !0; | ||
if ("function" != typeof func) throw new TypeError(FUNC_ERROR_TEXT); | ||
return wait = toNumber(wait) || 0, isObject(options) && (leading = !!options.leading, | ||
maxing = "maxWait" in options, maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait, | ||
trailing = "trailing" in options ? !!options.trailing : trailing), debounced.cancel = cancel, | ||
debounced.flush = flush, debounced; | ||
} | ||
function throttle(func, wait, options) { | ||
var leading = !0, trailing = !0; | ||
if ("function" != typeof func) throw new TypeError(FUNC_ERROR_TEXT); | ||
return isObject(options) && (leading = "leading" in options ? !!options.leading : leading, | ||
trailing = "trailing" in options ? !!options.trailing : trailing), debounce(func, wait, { | ||
leading: leading, | ||
maxWait: wait, | ||
trailing: trailing | ||
}); | ||
} | ||
function isObject(value) { | ||
var type = typeof value; | ||
return !!value && ("object" == type || "function" == type); | ||
} | ||
function isObjectLike(value) { | ||
return !!value && "object" == typeof value; | ||
} | ||
function isSymbol(value) { | ||
return "symbol" == typeof value || isObjectLike(value) && objectToString.call(value) == symbolTag; | ||
} | ||
function toNumber(value) { | ||
if ("number" == typeof value) return value; | ||
if (isSymbol(value)) return NAN; | ||
if (isObject(value)) { | ||
var other = "function" == typeof value.valueOf ? value.valueOf() : value; | ||
value = isObject(other) ? other + "" : other; | ||
} | ||
if ("string" != typeof value) return 0 === value ? value : +value; | ||
value = value.replace(reTrim, ""); | ||
var isBinary = reIsBinary.test(value); | ||
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; | ||
} | ||
var FUNC_ERROR_TEXT = "Expected a function", NAN = NaN, symbolTag = "[object Symbol]", reTrim = /^\s+|\s+$/g, reIsBadHex = /^[-+]0x[0-9a-f]+$/i, reIsBinary = /^0b[01]+$/i, reIsOctal = /^0o[0-7]+$/i, freeParseInt = parseInt, freeGlobal = "object" == typeof global && global && global.Object === Object && global, freeSelf = "object" == typeof self && self && self.Object === Object && self, root = freeGlobal || freeSelf || Function("return this")(), objectProto = Object.prototype, objectToString = objectProto.toString, nativeMax = Math.max, nativeMin = Math.min, now = function() { | ||
return root.Date.now(); | ||
}; | ||
return function() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; | ||
timeout || (callbackArgs = args, timeout = setTimeout(later, wait)); | ||
}; | ||
module.exports = throttle; | ||
}).call(exports, __webpack_require__(3)); | ||
}, function(module, exports) { | ||
var g; | ||
g = function() { | ||
return this; | ||
}(); | ||
try { | ||
g = g || Function("return this")() || (0, eval)("this"); | ||
} catch (e) { | ||
"object" == typeof window && (g = window); | ||
} | ||
module.exports = throttle; | ||
module.exports = g; | ||
} ]); | ||
}); |
module.exports = { | ||
preset: 'jest-puppeteer', | ||
moduleNameMapper: { | ||
jquery: '<rootDir>/example/jquery-1.12.4.js', | ||
jquery: '<rootDir>/test/assets/jquery-1.12.4.js', | ||
}, | ||
testRegex: 'test/.*\\.spec\\.js$', | ||
}; |
{ | ||
"name": "jquery-sticky-table-header", | ||
"version": "0.2.2", | ||
"version": "1.0.0", | ||
"main": "build/jquery.stickyTableHeader.js", | ||
@@ -8,4 +8,4 @@ "author": "Simon Smith", | ||
"devDependencies": { | ||
"babel-eslint": "^7.2.3", | ||
"babel-jest": "^20.0.3", | ||
"babel-eslint": "^8.2.2", | ||
"babel-jest": "^22.4.3", | ||
"babel-loader": "^7.1.2", | ||
@@ -17,7 +17,11 @@ "babel-plugin-transform-class-properties": "^6.24.1", | ||
"eslint": "^4.5.0", | ||
"eslint-config-airbnb-base": "^11.3.1", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"http-server": "^0.10.0", | ||
"jest": "^20.0.4", | ||
"puppeteer": "^0.9.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"http-server": "^0.11.1", | ||
"jest": "^22.4.3", | ||
"jest-puppeteer": "^2.2.1", | ||
"prettier": "^1.11.1", | ||
"puppeteer": "^1.2.0", | ||
"uglifyjs-webpack-plugin": "^0.4.6", | ||
@@ -37,9 +41,13 @@ "webpack": "^3.5.5" | ||
"dev": "cross-env NODE_ENV=development webpack --watch", | ||
"lint": "eslint src test", | ||
"lint": "eslint src webpack.config.js test/browser.spec.js", | ||
"pretest": "yarn run build", | ||
"posttest": "yarn run lint", | ||
"test": "jest", | ||
"prepublishOnly": "npm run build", | ||
"test-server": "http-server -p 3002 -s &", | ||
"prepublishOnly": "yarn run build", | ||
"server": "http-server -p 3002 -c-1", | ||
"start": "concurrently \"npm run server\" \"npm run dev\"" | ||
"start": "concurrently \"yarn run server\" \"yarn run dev\"" | ||
}, | ||
"dependencies": { | ||
"lodash.throttle": "^4.1.1" | ||
} | ||
} |
@@ -21,3 +21,4 @@ # jquery.stickyTableHeader [![Build Status](https://travis-ci.org/simonsmith/jquery.stickyTableHeader.svg?branch=master)](https://travis-ci.org/simonsmith/jquery.stickyTableHeader) | ||
It's recommended to `require`/`import` the plugin as part of an existing webpack or browserify setup: | ||
It's recommended to `require`/`import` the plugin as part of an existing [webpack](https://webpack.js.org/) | ||
or [browserify](http://browserify.org/) setup: | ||
@@ -40,6 +41,11 @@ ``` | ||
Clone the repository and run `npm install && npm run build`. This will generate | ||
a UMD version of the plugin in `./build` that can be dropped into a project | ||
however you want. | ||
1. Clone the repository | ||
1. `yarn && yarn run build` or `npm install && npm run build` | ||
1. A [UMD | ||
version](https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) of | ||
the plugin will be available in the `./build` directory. | ||
1. Include it in your project as needed | ||
**Example** | ||
```html | ||
@@ -78,3 +84,3 @@ <script src="http://code.jquery.com/jquery-latest.js"></script> | ||
It's recommended that you apply a background colour to the header to mask the | ||
real table header beneath it. | ||
real table header beneath it. | ||
@@ -109,6 +115,9 @@ ## Options | ||
[yarn](https://yarnpkg.com/) is required or you can use `npm` to run the | ||
individual scripts yourself | ||
1. Clone the repository | ||
1. `npm install` | ||
1. `npm start` | ||
1. `yarn` | ||
1. `yarn start` | ||
Run the tests with `npm test` and view the demo at `http://localhost:3002/test` | ||
Run the tests with `yarn test` and view the demo at `http://localhost:3002/test` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances 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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
568974
11
290
1
120
2
19
3
+ Addedlodash.throttle@^4.1.1
+ Addedlodash.throttle@4.1.1(transitive)