+2
-1
@@ -14,3 +14,4 @@ { | ||
| "window": true, | ||
| "Event": true | ||
| "Event": true, | ||
| "HTMLElement": true | ||
| }, | ||
@@ -17,0 +18,0 @@ "rules": { |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v1.1.2 | ||
| @version v1.1.3 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
@@ -10,3 +10,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| * mouseCase | ||
| * @param {target} string || node | ||
| * @param {target} string | ||
| * @param {props} object | ||
@@ -25,3 +25,3 @@ * @param {props.cssClass} string | ||
| props: { | ||
| el: !target ? null : typeof target === 'string' ? document.querySelector(target) : target, | ||
| el: !target ? null : document.querySelector(target), | ||
| cssClass: cssClass, | ||
@@ -28,0 +28,0 @@ rule: rule, |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v1.1.2 | ||
| @version v1.1.3 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
@@ -16,3 +16,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| * mouseCase | ||
| * @param {target} string || node | ||
| * @param {target} string | ||
| * @param {props} object | ||
@@ -31,3 +31,3 @@ * @param {props.cssClass} string | ||
| props: { | ||
| el: !target ? null : typeof target === 'string' ? document.querySelector(target) : target, | ||
| el: !target ? null : document.querySelector(target), | ||
| cssClass: cssClass, | ||
@@ -34,0 +34,0 @@ rule: rule, |
| /** | ||
| mousecase - Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse! | ||
| @version v1.1.2 | ||
| @version v1.1.3 | ||
| @link https://github.com/yowainwright/mousecase#readme | ||
@@ -8,2 +8,2 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
| **/ | ||
| !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:t?"string"==typeof t?document.querySelector(t):t:null,cssClass:o,rule:r,activeClass:o+"--is-active"},state:{isDown:!1,startx:null,scrollLeft:null,isOn:!1},__proto__:{canUseMouseCase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e||!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=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:t?document.querySelector(t):null,cssClass:o,rule:r,activeClass:o+"--is-active"},state:{isDown:!1,startx:null,scrollLeft:null,isOn:!1},__proto__:{canUseMouseCase:function(t,e){return!(!t||1<document.querySelectorAll(t).length||!1===e||!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}}}}}); |
+3
-3
| { | ||
| "name": "mousecase", | ||
| "version": "1.1.2", | ||
| "version": "1.1.3", | ||
| "description": "Mousecase is a JavaScript utility supporting touch-like horizontal scrolling with a mouse!", | ||
@@ -68,5 +68,5 @@ "main": "dist/mousecase.js", | ||
| "markdown-spellcheck": "^1.3.1", | ||
| "markdownlint-cli": "^0.16.0", | ||
| "markdownlint-cli": "^0.17.0", | ||
| "puppeteer": "^1.11.0", | ||
| "rollup": "1.12.3", | ||
| "rollup": "1.15.6", | ||
| "rollup-plugin-babel": "4.3.2", | ||
@@ -73,0 +73,0 @@ "rollup-plugin-replace": "2.2.0", |
@@ -6,3 +6,3 @@ import { mouseCaseDom } from '../../utils/mock-data' | ||
| describe('mouseCase init', () => { | ||
| it('initiates', () => { | ||
| it('initiates basic target', () => { | ||
| document.body.innerHTML = mouseCaseDom | ||
@@ -12,4 +12,23 @@ const test = mousecase('#mouse-case') | ||
| 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('does not manage state w/o target', () => { | ||
| document.body.innerHTML = mouseCaseDom | ||
| const test = mousecase() | ||
| test.init() | ||
| test.manageState = jest.fn() | ||
| expect(test.state.isOn).toBe(false) | ||
| expect(test.manageState).not.toHaveBeenCalled() | ||
| }) | ||
| it('takes in props', () => { | ||
@@ -46,3 +65,5 @@ document.body.innerHTML = mouseCaseDom | ||
| document.body.innerHTML = mouseCaseDom | ||
| const test = mousecase('#mouse-case').init() | ||
| const test = mousecase('#mouse-case') | ||
| test.init() | ||
| test.mouseDown = jest.fn() | ||
| const e = new Event('mousedown') | ||
@@ -53,2 +74,3 @@ const testEl = document.getElementById('mouse-case') | ||
| expect(test.state.isDown).toBe(true) | ||
| expect(test.mouseDown).toHaveBeenCalled() | ||
| }) | ||
@@ -59,3 +81,5 @@ }) | ||
| document.body.innerHTML = mouseCaseDom | ||
| const test = mousecase('#mouse-case').init() | ||
| const test = mousecase('#mouse-case') | ||
| test.init() | ||
| test.mouseMove = jest.fn() | ||
| const e = new Event('mousedown') | ||
@@ -65,3 +89,4 @@ const testEl = document.getElementById('mouse-case') | ||
| testEl.addEventListener('mousemove', () => { | ||
| expect(test.state.isDown).toBe(false) | ||
| expect(test.state.isDown).toBe(true) | ||
| expect(test.mouseMove).toHaveBeenCalled() | ||
| }) | ||
@@ -80,2 +105,18 @@ }) | ||
| }) | ||
| it('manage state basics', () => { | ||
| document.body.innerHTML = mouseCaseDom | ||
| const test = mousecase('#mouse-case') | ||
| test.init() | ||
| test.manageState() | ||
| expect(test.state.isOn).toBe(true) | ||
| }) | ||
| it('manageState should be returned out of', () => { | ||
| document.body.innerHTML = mouseCaseDom | ||
| const test = mousecase() | ||
| test.init() | ||
| test.manageState() | ||
| expect(test.state.isOn).toBe(false) | ||
| }) | ||
| }) |
+2
-2
| /** | ||
| * mouseCase | ||
| * @param {target} string || node | ||
| * @param {target} string | ||
| * @param {props} object | ||
@@ -16,3 +16,3 @@ * @param {props.cssClass} string | ||
| props: { | ||
| el: !target ? null : typeof target === 'string' ? document.querySelector(target) : target, | ||
| el: !target ? null : document.querySelector(target), | ||
| cssClass, | ||
@@ -19,0 +19,0 @@ rule, |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed 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
618
6.37%37136
-87.85%27
-3.57%