| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return this; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return this; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| export { mousecase as default }; |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.jquery = global.jquery || {}, global.jquery.mousecase = factory())); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return this; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return this; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| })); |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).jquery=t.jquery||{},t.jquery.mousecase=e())}(this,function(){"use strict";return function(t,e){var e=void 0===e?{}:e,s=e.cssClass,s=void 0===s?"js-mousecase":s,e=e.rule,e=void 0===e||e;return{props:{el:document.querySelector(t),cssClass:s,rule:e,activeClass:"".concat(s,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){var e;return this.state.isDown&&(t.preventDefault(),e=this.props.el,t=3*(t.pageX-e.offsetLeft-this.state.startx),e.scrollLeft=this.state.scrollLeft-t),this},mouseDown:function(t){var e=this.props,s=e.activeClass,e=e.el;return this.state.isDown=!0,e.classList.add(s),this.state.startx=t.pageX-e.offsetLeft,this.state.scrollLeft=e.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var t,e=this;return this.state.isOn&&((t=this.props.el).addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()})),this},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v2.0.0 | ||
| @version v3.0.0 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
@@ -15,3 +15,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| rule: rule, | ||
| activeClass: cssClass + "--is-active", | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
@@ -33,3 +33,3 @@ state: { | ||
| if (!this.state.isDown) | ||
| return; | ||
| return this; | ||
| e.preventDefault(); | ||
@@ -59,3 +59,3 @@ var el = this.props.el; | ||
| if (!this.state.isOn) | ||
| return; | ||
| return this; | ||
| var el = this.props.el; | ||
@@ -85,2 +85,2 @@ el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| export default mousecase; | ||
| export { mousecase as default }; |
+79
-79
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v2.0.0 | ||
| @version v3.0.0 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
@@ -9,83 +9,83 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = global || self, global.mousecase = factory()); | ||
| }(this, function () { 'use strict'; | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mousecase = factory()); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: cssClass + "--is-active", | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return this; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return this; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| return mousecase; | ||
| })); |
@@ -1,8 +0,1 @@ | ||
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v2.0.0 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).mousecase=e()}(this,function(){"use strict";return function(t,e){var s=void 0===e?{}:e,n=s.cssClass,o=void 0===n?"js-mousecase":n,i=s.rule,r=void 0===i||i;return{props:{el:document.querySelector(t),cssClass:o,rule:r,activeClass:o+"--is-active"},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){if(this.state.isDown){t.preventDefault();var e=this.props.el,s=3*(t.pageX-e.offsetLeft-this.state.startx);return e.scrollLeft=this.state.scrollLeft-s,this}},mouseDown:function(t){var e=this.props,s=e.activeClass,n=e.el;return this.state.isDown=!0,n.classList.add(s),this.state.startx=t.pageX-n.offsetLeft,this.state.scrollLeft=n.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var e=this;if(this.state.isOn){var t=this.props.el;return t.addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()}),this}},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mousecase=e()}(this,function(){"use strict";return function(t,e){var e=void 0===e?{}:e,s=e.cssClass,s=void 0===s?"js-mousecase":s,e=e.rule,e=void 0===e||e;return{props:{el:document.querySelector(t),cssClass:s,rule:e,activeClass:"".concat(s,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){var e;return this.state.isDown&&(t.preventDefault(),e=this.props.el,t=3*(t.pageX-e.offsetLeft-this.state.startx),e.scrollLeft=this.state.scrollLeft-t),this},mouseDown:function(t){var e=this.props,s=e.activeClass,e=e.el;return this.state.isDown=!0,e.classList.add(s),this.state.startx=t.pageX-e.offsetLeft,this.state.scrollLeft=e.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var t,e=this;return this.state.isOn&&((t=this.props.el).addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()})),this},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
+50
-34
| { | ||
| "name": "mousecase", | ||
| "version": "3.0.0-beta.1", | ||
| "version": "3.0.0", | ||
| "description": "Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse!", | ||
@@ -8,2 +8,6 @@ "main": "dist/mousecase.js", | ||
| "unpkg": "dist/mousecase.min.js", | ||
| "types": "dist/mousecase.d.ts", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
@@ -13,16 +17,47 @@ "build": "rollup --config rollup.config.ts", | ||
| "eslint:ci": "eslint . --ext .js,.ts", | ||
| "chore:delete-changelog-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi", | ||
| "chore:branch": "git checkout -b chore-changelog", | ||
| "chore:changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r 0", | ||
| "chore:setup-next-work": "git checkout master && npm run chore:delete-changelog-branch", | ||
| "chore:pr": "git add . && git commit -m '[chore] updates changelog' --no-verify && git push origin chore-changelog -f", | ||
| "chore:setup-changelog": "git checkout master && git pull", | ||
| "chore": "npm run chore:delete-changelog-branch && npm run chore:branch && npm run chore:changelog && npm run chore:pr && npm run chore:setup-next-work", | ||
| "prepush": "npm run build && npm test && npm run eslint && npm run prettier", | ||
| "prettier": "prettier -c .prettierrc '**/*.{ts}'", | ||
| "pre-commit-msg": "Echo 'Running pre-commit checks...' && exit 0", | ||
| "postpublish": "git tag $npm_package_version && git push origin --tags && npm run chore", | ||
| "start": "yarn", | ||
| "test": "jest --config jest.jsdom.json --coverage" | ||
| "prepush": "pnpm run build && pnpm test && pnpm run eslint && pnpm run prettier", | ||
| "prepublishOnly": "pnpm run prepush", | ||
| "prettier": "prettier -c .prettierrc 'src/**/*.ts' --write", | ||
| "start": "pnpm install", | ||
| "test": "jest --coverage" | ||
| }, | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^22.0.2", | ||
| "@rollup/plugin-node-resolve": "^13.3.0", | ||
| "@rollup/plugin-typescript": "^8.4.0", | ||
| "@types/jest": "^27.5.2", | ||
| "@typescript-eslint/eslint-plugin": "^2.34.0", | ||
| "@typescript-eslint/parser": "^2.34.0", | ||
| "codecov": "^3.8.3", | ||
| "conventional-changelog-cli": "^2.2.2", | ||
| "eslint": "^6.8.0", | ||
| "husky": "^8.0.1", | ||
| "jest": "26.6.3", | ||
| "prettier": "^2.7.1", | ||
| "rollup": "^2.79.0", | ||
| "rollup-plugin-uglify": "6.0.4", | ||
| "ts-jest": "^26.5.6", | ||
| "tslib": "^2.4.0", | ||
| "typescript": "^4.8.2" | ||
| }, | ||
| "jest": { | ||
| "transform": { | ||
| ".ts": "ts-jest" | ||
| }, | ||
| "collectCoverageFrom": [ | ||
| "src/**/*.{js,ts}" | ||
| ], | ||
| "moduleFileExtensions": [ | ||
| "js", | ||
| "ts" | ||
| ], | ||
| "roots": [ | ||
| "src" | ||
| ], | ||
| "testEnvironment": "jsdom", | ||
| "testMatch": [ | ||
| "<rootDir>/**/__tests__/**/*.ts" | ||
| ], | ||
| "testURL": "http://localhost" | ||
| }, | ||
| "repository": { | ||
@@ -46,22 +81,3 @@ "type": "git", | ||
| }, | ||
| "homepage": "https://github.com/yowainwright/mousecase#readme", | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^21.0.1", | ||
| "@rollup/plugin-node-resolve": "^13.1.3", | ||
| "@rollup/plugin-typescript": "^8.3.0", | ||
| "@types/jest": "^27.0.1", | ||
| "@typescript-eslint/eslint-plugin": "^2.0.0", | ||
| "@typescript-eslint/parser": "^2.0.0", | ||
| "codecov": "^3.3.0", | ||
| "conventional-changelog-cli": "^2.0.11", | ||
| "eslint": "^6.1.0", | ||
| "husky": "^7.0.1", | ||
| "jest": "26.6.3", | ||
| "prettier": "^2.2.1", | ||
| "rollup": "^2.38.0", | ||
| "rollup-plugin-uglify": "6.0.4", | ||
| "ts-jest": "^26.4.4", | ||
| "tslib": "^2.3.1", | ||
| "typescript": "^4.0.3" | ||
| } | ||
| "homepage": "https://github.com/yowainwright/mousecase#readme" | ||
| } |
-13
| { | ||
| "presets": [ | ||
| ["@babel/preset-env", { | ||
| "loose": true, | ||
| "targets": { | ||
| "browsers": [ | ||
| "defaults", | ||
| "ie >= 11" | ||
| ] | ||
| } | ||
| }] | ||
| ], | ||
| } |
| defaults: &defaults | ||
| working_directory: ~/code | ||
| docker: | ||
| - image: circleci/node:10 | ||
| environment: | ||
| NPM_CONFIG_LOGLEVEL: error # make npm commands less noisy | ||
| JOBS: max # https://gist.github.com/ralphtheninja/f7c45bdee00784b41fed | ||
| restore_cache: &restore_cache | ||
| keys: | ||
| - code-{{ .Branch }}-{{ checksum ".nvmrc" }}-{{ checksum "package.json" }} | ||
| - code-master-{{ checksum ".nvmrc" }}-{{ checksum "package.json" }} | ||
| save_cache: &save_cache | ||
| key: code-{{ .Branch }}-{{ checksum ".nvmrc" }}-{{ checksum "package.json" }} | ||
| paths: | ||
| - node_modules | ||
| version: 2 | ||
| jobs: | ||
| build: | ||
| <<: *defaults | ||
| steps: | ||
| - checkout | ||
| - restore_cache: *restore_cache | ||
| - run: npm install | ||
| - run: npm run eslint:ci | ||
| - run: yarn test | ||
| - run: npx codecov | ||
| - save_cache: *save_cache |
| root = true | ||
| [*] | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
| indent_style = space | ||
| indent_size = 2 | ||
| [*.js] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| [*.hbs] | ||
| insert_final_newline = false | ||
| indent_style = space | ||
| indent_size = 2 | ||
| [*.{css,sass,scss}] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| [*.html] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| [*.{jade,pug}] | ||
| trim_trailing_whitespace = false | ||
| [*.{diff,md}] | ||
| trim_trailing_whitespace = false | ||
Sorry, the diff of this file is not supported yet
-35
| { | ||
| "parser": "@typescript-eslint/parser", | ||
| "extends": [ | ||
| "plugin:@typescript-eslint/recommended", | ||
| ], | ||
| "parserOptions": { | ||
| "ecmaVersion": 2018, | ||
| "sourceType": "module", | ||
| }, | ||
| "globals": { | ||
| "afterAll": true, | ||
| "beforeAll": true, | ||
| "browser": true, | ||
| "describe": true, | ||
| "document": true, | ||
| "expect": true, | ||
| "it": true, | ||
| "jest": true, | ||
| "test": true, | ||
| "window": true, | ||
| "Event": true, | ||
| "HTMLElement": true | ||
| }, | ||
| "rules": { | ||
| "no-console": "off", | ||
| "trailingComma": 0, | ||
| "semi": "off", | ||
| "indent": "off", | ||
| "@typescript-eslint/no-angle-bracket-type-assertion": 0, | ||
| "@typescript-eslint/no-object-literal-type-assertion": 0, | ||
| "@typescript-eslint/explicit-function-return-type": 0, | ||
| "@typescript-eslint/semi": ["error"], | ||
| "@typescript-eslint/indent": ["error", 2] | ||
| } | ||
| } |
| version: 2 | ||
| updates: | ||
| - package-ecosystem: npm | ||
| directory: "/" | ||
| schedule: | ||
| interval: daily | ||
| time: "13:00" | ||
| open-pull-requests-limit: 2 | ||
| ignore: | ||
| - dependency-name: puppeteer | ||
| versions: | ||
| - 6.0.0 | ||
| - 7.0.1 | ||
| - 7.0.4 | ||
| - 8.0.0 | ||
| - dependency-name: "@babel/preset-env" | ||
| versions: | ||
| - 7.12.13 | ||
| - 7.13.10 | ||
| - 7.13.12 | ||
| - dependency-name: "@babel/core" | ||
| versions: | ||
| - 7.13.10 | ||
| - 7.13.13 | ||
| - dependency-name: typescript | ||
| versions: | ||
| - 4.1.5 | ||
| - 4.2.2 | ||
| - dependency-name: "@babel/plugin-proposal-class-properties" | ||
| versions: | ||
| - 7.12.13 | ||
| - dependency-name: husky | ||
| versions: | ||
| - 5.0.9 | ||
| - dependency-name: write-good | ||
| versions: | ||
| - 1.0.7 |
| ## Requested Update | ||
| ## Why Is This Update Needed? | ||
| ## Are There Examples Of This Requested Update Elsewhere? | ||
| > Read about references issues [here](https://help.github.com/articles/closing-issues-using-keywords/). Provide paragraph text responses to each header. |
| ## Fixes | ||
| - Fixes # | ||
| ## Proposed Changes | ||
| - Change | ||
| ---- | ||
| > Read about referenced issues [here](https://help.github.com/articles/closing-issues-using-keywords/). Replace words with this Pull Request's context. |
| name: "CodeQL" | ||
| on: | ||
| push: | ||
| branches: [master, ] | ||
| pull_request: | ||
| # The branches below must be a subset of the branches above | ||
| branches: [master] | ||
| schedule: | ||
| - cron: '0 12 * * 6' | ||
| jobs: | ||
| analyze: | ||
| name: Analyze | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| # We must fetch at least the immediate parents so that if this is | ||
| # a pull request then we can checkout the head. | ||
| fetch-depth: 2 | ||
| # If this run was triggered by a pull request event, then checkout | ||
| # the head of the pull request instead of the merge commit. | ||
| - run: git checkout HEAD^2 | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| # Initializes the CodeQL tools for scanning. | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v1 | ||
| # Override language selection by uncommenting this and choosing your languages | ||
| # with: | ||
| # languages: go, javascript, csharp, python, cpp, java | ||
| # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
| # If this step fails, then you should remove it and run the build manually (see below) | ||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v1 | ||
| # ℹ️ Command-line programs to run using the OS shell. | ||
| # 📚 https://git.io/JvXDl | ||
| # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
| # and modify them (or add more) to build your code if your project | ||
| # uses a compiled language | ||
| #- run: | | ||
| # make bootstrap | ||
| # make release | ||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v1 |
| # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
| name: Node.js CI | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: [16.x] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: yarn | ||
| - run: yarn eslint:ci | ||
| - run: yarn test | ||
| - run: npx codecov |
Sorry, the diff of this file is not supported yet
-1
| 16 |
| { | ||
| "arrowParens": "always", | ||
| "semi": true, | ||
| "singleQuote": true, | ||
| "tabWidth": 2, | ||
| "trailingComma": "es5", | ||
| "quoteProps": "consistent" | ||
| } |
Sorry, the diff of this file is not supported yet
| ## [2.0.1](https://github.com/yowainwright/mousecase/compare/2.0.0...2.0.1) (2021-09-22) | ||
| ### GitBook | ||
| * [master] 2 pages modified ([8bd4de6](https://github.com/yowainwright/mousecase/commit/8bd4de66c0fba1a0dc641b4e676ed56adf7b6a73)) | ||
| # Contributor Covenant Code of Conduct | ||
| ## Our Pledge | ||
| In the interest of fostering an open and welcoming environment, we as | ||
| contributors and maintainers pledge to making participation in our project and | ||
| our community a harassment-free experience for everyone, regardless of age, body | ||
| size, disability, ethnicity, sex characteristics, gender identity and expression, | ||
| level of experience, education, socio-economic status, nationality, personal | ||
| appearance, race, religion, or sexual identity and orientation. | ||
| ## Our Standards | ||
| Examples of behavior that contributes to creating a positive environment | ||
| include: | ||
| * Using welcoming and inclusive language | ||
| * Being respectful of differing viewpoints and experiences | ||
| * Accepting constructive criticism | ||
| * Focusing on what is best for the community | ||
| * Showing empathy towards other community members | ||
| Examples of unacceptable behavior by participants include: | ||
| * The use of sexualized language or imagery and unwelcome sexual attention or | ||
| advances | ||
| * Trolling, insulting/derogatory comments, and personal or political attacks | ||
| * Public or private harassment | ||
| * Publishing others' private information, such as a physical or electronic | ||
| address, without explicit permission | ||
| * Other conduct which could reasonably be considered inappropriate in a | ||
| professional setting | ||
| ## Our Responsibilities | ||
| Project maintainers are responsible for clarifying the standards of acceptable | ||
| behavior and are expected to take appropriate and fair corrective action in | ||
| response to any instances of unacceptable behavior. | ||
| Project maintainers have the right and responsibility to remove, edit, or | ||
| reject comments, commits, code, wiki edits, issues, and other contributions | ||
| that are not aligned to this Code of Conduct, or to ban temporarily or | ||
| permanently any contributor for other behaviors that they deem inappropriate, | ||
| threatening, offensive, or harmful. | ||
| ## Scope | ||
| This Code of Conduct applies both within project spaces and in public spaces | ||
| when an individual is representing the project or its community. Examples of | ||
| representing a project or community include using an official project e-mail | ||
| address, posting via an official social media account, or acting as an appointed | ||
| representative at an online or offline event. Representation of a project may be | ||
| further defined and clarified by project maintainers. | ||
| ## Enforcement | ||
| Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
| reported by contacting the project team at [INSERT EMAIL ADDRESS]. All | ||
| complaints will be reviewed and investigated and will result in a response that | ||
| is deemed necessary and appropriate to the circumstances. The project team is | ||
| obligated to maintain confidentiality with regard to the reporter of an incident. | ||
| Further details of specific enforcement policies may be posted separately. | ||
| Project maintainers who do not follow or enforce the Code of Conduct in good | ||
| faith may face temporary or permanent repercussions as determined by other | ||
| members of the project's leadership. | ||
| ## Attribution | ||
| This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at [Contributor Covenant, Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html) |
Sorry, the diff of this file is not supported yet
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| export { mousecase as default }; |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.jquery = global.jquery || {}, global.jquery.noframe = factory())); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| })); |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).jquery=t.jquery||{},t.jquery.noframe=e())}(this,function(){"use strict";return function(t,e){var s=void 0===e?{}:e,n=s.cssClass,o=void 0===n?"js-mousecase":n,i=s.rule,r=void 0===i||i;return{props:{el:document.querySelector(t),cssClass:o,rule:r,activeClass:"".concat(o,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){if(this.state.isDown){t.preventDefault();var e=this.props.el,s=3*(t.pageX-e.offsetLeft-this.state.startx);return e.scrollLeft=this.state.scrollLeft-s,this}},mouseDown:function(t){var e=this.props,s=e.activeClass,n=e.el;return this.state.isDown=!0,n.classList.add(s),this.state.startx=t.pageX-n.offsetLeft,this.state.scrollLeft=n.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var e=this;if(this.state.isOn){var t=this.props.el;return t.addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()}),this}},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| export { mousecase as default }; |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.jquery = global.jquery || {}, global.jquery.reframe = factory())); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| })); |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).jquery=t.jquery||{},t.jquery.reframe=e())}(this,function(){"use strict";return function(t,e){var s=void 0===e?{}:e,n=s.cssClass,o=void 0===n?"js-mousecase":n,i=s.rule,r=void 0===i||i;return{props:{el:document.querySelector(t),cssClass:o,rule:r,activeClass:"".concat(o,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){if(this.state.isDown){t.preventDefault();var e=this.props.el,s=3*(t.pageX-e.offsetLeft-this.state.startx);return e.scrollLeft=this.state.scrollLeft-s,this}},mouseDown:function(t){var e=this.props,s=e.activeClass,n=e.el;return this.state.isDown=!0,n.classList.add(s),this.state.startx=t.pageX-n.offsetLeft,this.state.scrollLeft=n.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var e=this;if(this.state.isOn){var t=this.props.el;return t.addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()}),this}},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| export { mousecase as default }; |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.noframe = factory()); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| })); |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).noframe=e()}(this,function(){"use strict";return function(t,e){var s=void 0===e?{}:e,n=s.cssClass,o=void 0===n?"js-mousecase":n,i=s.rule,r=void 0===i||i;return{props:{el:document.querySelector(t),cssClass:o,rule:r,activeClass:"".concat(o,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){if(this.state.isDown){t.preventDefault();var e=this.props.el,s=3*(t.pageX-e.offsetLeft-this.state.startx);return e.scrollLeft=this.state.scrollLeft-s,this}},mouseDown:function(t){var e=this.props,s=e.activeClass,n=e.el;return this.state.isDown=!0,n.classList.add(s),this.state.startx=t.pageX-n.offsetLeft,this.state.scrollLeft=n.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var e=this;if(this.state.isOn){var t=this.props.el;return t.addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()}),this}},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| export { mousecase as default }; |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v3.0.0-beta.1 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
| @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| @license MIT | ||
| **/ | ||
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.reframe = factory()); | ||
| })(this, (function () { 'use strict'; | ||
| var mousecase = function (target, _a) { | ||
| var _b = _a === void 0 ? {} : _a, _c = _b.cssClass, cssClass = _c === void 0 ? 'js-mousecase' : _c, _d = _b.rule, rule = _d === void 0 ? true : _d; | ||
| return ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass: cssClass, | ||
| rule: rule, | ||
| activeClass: "".concat(cssClass, "--is-active"), | ||
| }, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| }, | ||
| canUseMousecase: function (target, rule) { | ||
| if (!target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false) | ||
| return false; | ||
| return true; | ||
| }, | ||
| mouseMove: function (e) { | ||
| if (!this.state.isDown) | ||
| return; | ||
| e.preventDefault(); | ||
| var el = this.props.el; | ||
| var initial = e.pageX - el.offsetLeft; | ||
| var distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown: function (e) { | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown: function () { | ||
| this.state.isDown = false; | ||
| var _a = this.props, activeClass = _a.activeClass, el = _a.el; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState: function () { | ||
| var _this = this; | ||
| if (!this.state.isOn) | ||
| return; | ||
| var el = this.props.el; | ||
| el.addEventListener('mousemove', function (e) { return _this.mouseMove(e); }); | ||
| el.addEventListener('mousedown', function (e) { return _this.mouseDown(e); }); | ||
| el.addEventListener('mouseleave', function () { return _this.mouseNotDown(); }); | ||
| el.addEventListener('mouseup', function () { return _this.mouseNotDown(); }); | ||
| return this; | ||
| }, | ||
| init: function () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) | ||
| return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off: function () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on: function () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| }; | ||
| return mousecase; | ||
| })); |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).reframe=e()}(this,function(){"use strict";return function(t,e){var s=void 0===e?{}:e,n=s.cssClass,o=void 0===n?"js-mousecase":n,i=s.rule,r=void 0===i||i;return{props:{el:document.querySelector(t),cssClass:o,rule:r,activeClass:"".concat(o,"--is-active")},state:{isDown:!1,startx:0,scrollLeft:0,isOn:!1},canUseMousecase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e)},mouseMove:function(t){if(this.state.isDown){t.preventDefault();var e=this.props.el,s=3*(t.pageX-e.offsetLeft-this.state.startx);return e.scrollLeft=this.state.scrollLeft-s,this}},mouseDown:function(t){var e=this.props,s=e.activeClass,n=e.el;return this.state.isDown=!0,n.classList.add(s),this.state.startx=t.pageX-n.offsetLeft,this.state.scrollLeft=n.scrollLeft,this},mouseNotDown:function(){this.state.isDown=!1;var t=this.props,e=t.activeClass;return t.el.classList.remove(e),this},manageState:function(){var e=this;if(this.state.isOn){var t=this.props.el;return t.addEventListener("mousemove",function(t){return e.mouseMove(t)}),t.addEventListener("mousedown",function(t){return e.mouseDown(t)}),t.addEventListener("mouseleave",function(){return e.mouseNotDown()}),t.addEventListener("mouseup",function(){return e.mouseNotDown()}),this}},init:function(){this.canUseMousecase(t,this.props.rule)&&(this.state.isOn=!0,this.manageState())},off:function(){return this.state.isOn=!1,this},on:function(){return this.state.isOn=!0,this}}}}); |
| { | ||
| "transform": { | ||
| ".ts": "ts-jest" | ||
| }, | ||
| "collectCoverageFrom": [ | ||
| "src/**/*.{js,ts}" | ||
| ], | ||
| "moduleFileExtensions": [ | ||
| "js", | ||
| "ts" | ||
| ], | ||
| "roots": [ | ||
| "src" | ||
| ], | ||
| "testEnvironment": "jsdom", | ||
| "testMatch": [ | ||
| "<rootDir>/**/__tests__/**/*.ts" | ||
| ], | ||
| "testURL": "http://localhost" | ||
| } |
| import { | ||
| author, | ||
| description, | ||
| homepage, | ||
| license, | ||
| name, | ||
| version, | ||
| } from './package.json'; | ||
| import resolve from '@rollup/plugin-node-resolve'; | ||
| import commonjs from '@rollup/plugin-commonjs'; | ||
| import typescript from '@rollup/plugin-typescript'; | ||
| import { uglify } from 'rollup-plugin-uglify'; | ||
| const banner = `/** | ||
| ${name} - ${description} | ||
| @version v${version} | ||
| @link ${homepage} | ||
| @author ${author} | ||
| @license ${license} | ||
| **/`; | ||
| const plugins = [ | ||
| resolve(), | ||
| commonjs(), | ||
| typescript({ | ||
| tsconfig: false, | ||
| lib: ['esnext', 'dom', 'dom.iterable'], | ||
| target: 'es5', | ||
| }), | ||
| ]; | ||
| const inputs = ['reframe', 'noframe', 'jquery.reframe', 'jquery.noframe']; | ||
| const esRollups = inputs.map((name) => ({ | ||
| input: `src/index.ts`, | ||
| output: { banner, name, file: `dist/${name}.es.js`, format: 'es' }, | ||
| plugins, | ||
| })); | ||
| const umdRollups = inputs.map((name) => ({ | ||
| input: `src/index.ts`, | ||
| output: { banner, name, file: `dist/${name}.js`, format: 'umd' }, | ||
| plugins, | ||
| })); | ||
| const minRollups = inputs.map((name) => ({ | ||
| input: `src/index.ts`, | ||
| output: { banner, name, file: `dist/${name}.min.js`, format: 'umd' }, | ||
| plugins: [...plugins, uglify()], | ||
| })); | ||
| export default [...esRollups, ...umdRollups, ...minRollups]; |
-18
| # Security Policy | ||
| ## Supported Versions | ||
| Use this section to tell people about which versions of your project are | ||
| currently being supported with security updates. | ||
| | Version | Supported | | ||
| | ------- | ------------------ | | ||
| | 2.x.x | :white_check_mark: | | ||
| ## Reporting a Vulnerability | ||
| Use this section to tell people how to report a vulnerability. | ||
| Tell them where to go, how often they can expect to get an update on a | ||
| reported vulnerability, what to expect if the vulnerability is accepted or | ||
| declined, etc. |
| import { mouseCaseDom } from '../utils/mock-data'; | ||
| import mousecase from '..'; | ||
| type SelectedElement = any; | ||
| describe('mouseCase init', () => { | ||
| it('initiates basic target', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| expect(typeof test).toBe('object'); | ||
| expect(test.props.el instanceof HTMLElement).toBe(true); | ||
| }); | ||
| it('initiates basic target with options', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case', { rule: false, cssClass: 'foo-bar' }); | ||
| test.init(); | ||
| expect(typeof test).toBe('object'); | ||
| expect(test.props.rule).toBe(false); | ||
| expect(test.props.cssClass).toBe('foo-bar'); | ||
| }); | ||
| it('takes in props', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| expect(test.props.activeClass).toBe('js-mousecase--is-active'); | ||
| expect(test.props.el.id).toBe('mouse-case'); | ||
| expect(test.props.cssClass).toBe('js-mousecase'); | ||
| expect(test.props.rule).toBe(true); | ||
| }); | ||
| it('has initial state', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| expect(test.state.isDown).toBe(false); | ||
| expect(test.state.startx).toBe(0); | ||
| expect(test.state.scrollLeft).toBe(0); | ||
| expect(test.state.isOn).toBe(false); | ||
| test.init(); | ||
| expect(test.state.isOn).toBe(true); | ||
| }); | ||
| it('mouseDown', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| test.mouseDown = jest.fn(); | ||
| const e = new Event('mousedown'); | ||
| const testEl: SelectedElement = document.getElementById('mouse-case'); | ||
| testEl.dispatchEvent(e); | ||
| testEl.addEventListener('mousedown', () => { | ||
| expect(test.state.isDown).toBe(true); | ||
| expect(test.mouseDown).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
| it('mouseMove', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| test.mouseMove = jest.fn(); | ||
| const e = new Event('mousedown'); | ||
| const testEl: SelectedElement = document.getElementById('mouse-case'); | ||
| testEl.dispatchEvent(e); | ||
| testEl.addEventListener('mousemove', () => { | ||
| expect(test.state.isDown).toBe(true); | ||
| expect(test.mouseMove).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
| it('mouseup', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| test.mouseMove = jest.fn(); | ||
| const e = new Event('mouseup'); | ||
| const testEl: SelectedElement = document.getElementById('mouse-case'); | ||
| testEl.dispatchEvent(e); | ||
| testEl.addEventListener('mousemove', () => { | ||
| expect(test.state.isDown).toBe(false); | ||
| }); | ||
| }); | ||
| it('manage state basics', () => { | ||
| document.body.innerHTML = mouseCaseDom; | ||
| const test = mousecase('#mouse-case'); | ||
| test.init(); | ||
| test.manageState(); | ||
| expect(test.state.isOn).toBe(true); | ||
| }); | ||
| }); |
-111
| interface MousecasePropArguments { | ||
| cssClass?: string; | ||
| rule?: boolean; | ||
| } | ||
| interface MousecaseProps { | ||
| activeClass: string; | ||
| cssClass: string; | ||
| el: HTMLElement; | ||
| rule: boolean; | ||
| } | ||
| interface MousecaseState { | ||
| isDown: boolean; | ||
| startx: number; | ||
| scrollLeft: number; | ||
| isOn: boolean; | ||
| } | ||
| type MousecaseThis = any; | ||
| interface MousecaseResult { | ||
| props: MousecaseProps; | ||
| state: MousecaseState; | ||
| canUseMousecase: (target: string, rule: boolean) => boolean; | ||
| mouseMove: (e: MouseEvent) => MousecaseThis; | ||
| mouseDown: (e: MouseEvent) => MousecaseThis; | ||
| mouseNotDown: () => MousecaseThis; | ||
| manageState: () => MousecaseThis; | ||
| init: () => void; | ||
| off: () => MousecaseThis; | ||
| on: () => MousecaseThis; | ||
| } | ||
| const mousecase = ( | ||
| target: string, | ||
| { | ||
| cssClass = 'js-mousecase', | ||
| rule = true, | ||
| }: MousecasePropArguments = {} | ||
| ): MousecaseResult => ({ | ||
| props: { | ||
| el: document.querySelector(target), | ||
| cssClass, | ||
| rule, | ||
| activeClass: `${cssClass}--is-active`, | ||
| } as MousecaseProps, | ||
| state: { | ||
| isDown: false, | ||
| startx: 0, | ||
| scrollLeft: 0, | ||
| isOn: false, | ||
| } as MousecaseState, | ||
| canUseMousecase (target: string, rule: boolean): boolean { | ||
| if ( | ||
| !target || | ||
| document.querySelectorAll(target).length > 1 || | ||
| rule === false | ||
| ) return false; | ||
| return true; | ||
| }, | ||
| mouseMove (e: MouseEvent) { | ||
| if (!this.state.isDown) return; | ||
| e.preventDefault(); | ||
| const { el } = this.props; | ||
| const initial = e.pageX - el.offsetLeft; | ||
| const distance = (initial - this.state.startx) * 3; | ||
| el.scrollLeft = this.state.scrollLeft - distance; | ||
| return this; | ||
| }, | ||
| mouseDown (e: MouseEvent) { | ||
| const { activeClass, el } = this.props; | ||
| this.state.isDown = true; | ||
| el.classList.add(activeClass); | ||
| this.state.startx = e.pageX - el.offsetLeft; | ||
| this.state.scrollLeft = el.scrollLeft; | ||
| return this; | ||
| }, | ||
| mouseNotDown () { | ||
| this.state.isDown = false; | ||
| const { activeClass, el } = this.props; | ||
| el.classList.remove(activeClass); | ||
| return this; | ||
| }, | ||
| manageState () { | ||
| if (!this.state.isOn) return; | ||
| const { el } = this.props; | ||
| el.addEventListener('mousemove', (e) => this.mouseMove(e)); | ||
| el.addEventListener('mousedown', (e) => this.mouseDown(e)); | ||
| el.addEventListener('mouseleave', () => this.mouseNotDown()); | ||
| el.addEventListener('mouseup', () => this.mouseNotDown()); | ||
| return this; | ||
| }, | ||
| init () { | ||
| if (!this.canUseMousecase(target, this.props.rule)) return; | ||
| this.state.isOn = true; | ||
| this.manageState(); | ||
| }, | ||
| off () { | ||
| this.state.isOn = false; | ||
| return this; | ||
| }, | ||
| on () { | ||
| this.state.isOn = true; | ||
| return this; | ||
| }, | ||
| }); | ||
| export default mousecase; |
| /** | ||
| * mouseCaseDom | ||
| * - a dom for testing mouseCase, etc, etc | ||
| */ | ||
| export const mouseCaseDom = ` | ||
| <main class="main"> | ||
| <nav id="mouse-case" class="mouse-case"> | ||
| <ul class="mouse-case__items"> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/200/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/210/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/230/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/250/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/235/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/245/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| <li class="mouse-case__item"> | ||
| <figure class="mouse-case__figure"> | ||
| <a href="" class="mouse-case__link" /> | ||
| <img class="mouse-case__img" src="https://fillmurray.com/190/400" alt="mouse case" /> | ||
| <figcaption class="mouse-case__caption">Mouse Case!</figcaption> | ||
| </a> | ||
| </figure> | ||
| </li> | ||
| </ul> | ||
| </nav> | ||
| </main> | ||
| `; |
| # Table of contents | ||
| * [Initial page](README.md) | ||
| { | ||
| "compilerOptions": { | ||
| "moduleResolution": "node", | ||
| "target": "es5", | ||
| "module": "es2015", | ||
| "lib": ["es2015", "es2016", "es2017", "dom"], | ||
| "rootDir": "src/", | ||
| "strict": true, | ||
| "sourceMap": true, | ||
| "declaration": true, | ||
| "allowSyntheticDefaultImports": true, | ||
| "experimentalDecorators": true, | ||
| "emitDecoratorMetadata": true, | ||
| "declarationDir": "types", | ||
| "outDir": "dist/", | ||
| "typeRoots": ["node_modules/@types"] | ||
| }, | ||
| "include": ["src"], | ||
| "exclude": ["node_modules", "src/__tests__/*", "src/utils/*"] | ||
| } |
| export {}; |
| interface MousecasePropArguments { | ||
| cssClass?: string; | ||
| rule?: boolean; | ||
| } | ||
| interface MousecaseProps { | ||
| activeClass: string; | ||
| cssClass: string; | ||
| el: HTMLElement; | ||
| rule: boolean; | ||
| } | ||
| interface MousecaseState { | ||
| isDown: boolean; | ||
| startx: number; | ||
| scrollLeft: number; | ||
| isOn: boolean; | ||
| } | ||
| declare type MousecaseThis = any; | ||
| interface MousecaseResult { | ||
| props: MousecaseProps; | ||
| state: MousecaseState; | ||
| canUseMousecase: (target: string, rule: boolean) => boolean; | ||
| mouseMove: (e: MouseEvent) => MousecaseThis; | ||
| mouseDown: (e: MouseEvent) => MousecaseThis; | ||
| mouseNotDown: () => MousecaseThis; | ||
| manageState: () => MousecaseThis; | ||
| init: () => void; | ||
| off: () => MousecaseThis; | ||
| on: () => MousecaseThis; | ||
| } | ||
| declare const mousecase: (target: string, { cssClass, rule, }?: MousecasePropArguments) => MousecaseResult; | ||
| export default mousecase; |
| /** | ||
| * mouseCaseDom | ||
| * - a dom for testing mouseCase, etc, etc | ||
| */ | ||
| export declare const mouseCaseDom = "\n <main class=\"main\">\n <nav id=\"mouse-case\" class=\"mouse-case\">\n <ul class=\"mouse-case__items\">\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/200/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/210/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/230/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/250/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/235/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/245/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n <li class=\"mouse-case__item\">\n <figure class=\"mouse-case__figure\">\n <a href=\"\" class=\"mouse-case__link\" />\n <img class=\"mouse-case__img\" src=\"https://fillmurray.com/190/400\" alt=\"mouse case\" />\n <figcaption class=\"mouse-case__caption\">Mouse Case!</figcaption>\n </a>\n </figure>\n </li>\n </ul>\n </nav>\n </main>\n"; |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2
-66.67%0
-100%22504
-69.18%9
-80.43%350
-72.38%1
Infinity%