@scena/dragscroll
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -6,6 +6,7 @@ import Component from "@egjs/component"; | ||
private prevDirection; | ||
private startPos; | ||
private prevPos; | ||
dragStart(container: HTMLElement): void; | ||
dragStart(e: any, container: HTMLElement): void; | ||
drag(e: any, options: DragScrollOptions): boolean; | ||
dragAfter(e: any, options: DragScrollOptions): boolean; | ||
} |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
@@ -67,2 +67,3 @@ 'use strict'; | ||
_this.prevDirection = null; | ||
_this.startPos = []; | ||
_this.prevPos = []; | ||
@@ -74,3 +75,3 @@ return _this; | ||
__proto.dragStart = function (container) { | ||
__proto.dragStart = function (e, container) { | ||
var _a = container.getBoundingClientRect(), | ||
@@ -82,2 +83,3 @@ top = _a.top, | ||
this.startPos = [e.clientX, e.clientY]; | ||
this.startRect = { | ||
@@ -100,15 +102,27 @@ top: top, | ||
getScrollPosition = _b === void 0 ? getDefaultScrollPosition : _b; | ||
var startRect = this.startRect; | ||
var _c = this, | ||
startRect = _c.startRect, | ||
startPos = _c.startPos; | ||
var direction = [0, 0]; | ||
if (startRect.top > clientY - threshold) { | ||
direction[1] = -1; | ||
if (startPos[1] > startRect.top || clientY < startPos[1]) { | ||
direction[1] = -1; | ||
} | ||
} else if (startRect.top + startRect.height < clientY + threshold) { | ||
direction[1] = 1; | ||
if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { | ||
direction[1] = 1; | ||
} | ||
} | ||
if (startRect.left > clientX - threshold) { | ||
direction[0] = -1; | ||
if (startPos[0] > startRect.left || clientX < startPos[0]) { | ||
direction[0] = -1; | ||
} | ||
} else if (startRect.left + startRect.width < clientX + threshold) { | ||
direction[0] = 1; | ||
if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { | ||
direction[0] = 1; | ||
} | ||
} | ||
@@ -115,0 +129,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
@@ -65,2 +65,3 @@ import Component from '@egjs/component'; | ||
_this.prevDirection = null; | ||
_this.startPos = []; | ||
_this.prevPos = []; | ||
@@ -72,3 +73,3 @@ return _this; | ||
__proto.dragStart = function (container) { | ||
__proto.dragStart = function (e, container) { | ||
var _a = container.getBoundingClientRect(), | ||
@@ -80,2 +81,3 @@ top = _a.top, | ||
this.startPos = [e.clientX, e.clientY]; | ||
this.startRect = { | ||
@@ -98,15 +100,27 @@ top: top, | ||
getScrollPosition = _b === void 0 ? getDefaultScrollPosition : _b; | ||
var startRect = this.startRect; | ||
var _c = this, | ||
startRect = _c.startRect, | ||
startPos = _c.startPos; | ||
var direction = [0, 0]; | ||
if (startRect.top > clientY - threshold) { | ||
direction[1] = -1; | ||
if (startPos[1] > startRect.top || clientY < startPos[1]) { | ||
direction[1] = -1; | ||
} | ||
} else if (startRect.top + startRect.height < clientY + threshold) { | ||
direction[1] = 1; | ||
if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { | ||
direction[1] = 1; | ||
} | ||
} | ||
if (startRect.left > clientX - threshold) { | ||
direction[0] = -1; | ||
if (startPos[0] > startRect.left || clientX < startPos[0]) { | ||
direction[0] = -1; | ||
} | ||
} else if (startRect.left + startRect.width < clientX + threshold) { | ||
direction[0] = 1; | ||
if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { | ||
direction[0] = 1; | ||
} | ||
} | ||
@@ -113,0 +127,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
@@ -69,2 +69,3 @@ (function (global, factory) { | ||
_this.prevDirection = null; | ||
_this.startPos = []; | ||
_this.prevPos = []; | ||
@@ -76,3 +77,3 @@ return _this; | ||
__proto.dragStart = function (container) { | ||
__proto.dragStart = function (e, container) { | ||
var _a = container.getBoundingClientRect(), | ||
@@ -84,2 +85,3 @@ top = _a.top, | ||
this.startPos = [e.clientX, e.clientY]; | ||
this.startRect = { | ||
@@ -102,15 +104,27 @@ top: top, | ||
getScrollPosition = _b === void 0 ? getDefaultScrollPosition : _b; | ||
var startRect = this.startRect; | ||
var _c = this, | ||
startRect = _c.startRect, | ||
startPos = _c.startPos; | ||
var direction = [0, 0]; | ||
if (startRect.top > clientY - threshold) { | ||
direction[1] = -1; | ||
if (startPos[1] > startRect.top || clientY < startPos[1]) { | ||
direction[1] = -1; | ||
} | ||
} else if (startRect.top + startRect.height < clientY + threshold) { | ||
direction[1] = 1; | ||
if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { | ||
direction[1] = 1; | ||
} | ||
} | ||
if (startRect.left > clientX - threshold) { | ||
direction[0] = -1; | ||
if (startPos[0] > startRect.left || clientX < startPos[0]) { | ||
direction[0] = -1; | ||
} | ||
} else if (startRect.left + startRect.width < clientX + threshold) { | ||
direction[0] = 1; | ||
if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { | ||
direction[0] = 1; | ||
} | ||
} | ||
@@ -117,0 +131,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component")):"function"==typeof define&&define.amd?define(["@egjs/component"],e):(t=t||self).DragScroll=e(t.Component)}(this,function(t){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function l(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}return function(e){function t(){this.constructor=r}var r,n;function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.prevDirection=null,t.prevPos=[],t}c(r=o,n=e),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var i=o.prototype;return i.dragStart=function(t){var e=t.getBoundingClientRect(),r=e.top,n=e.left,o=e.width,i=e.height;this.startRect={top:r,left:n,width:o,height:i}},i.drag=function(t,e){var r=t.clientX,n=t.clientY;this.prevDirection=null;var o=e.container,i=e.threshold,c=void 0===i?0:i,s=e.getScrollPosition,p=void 0===s?l:s,f=this.startRect,u=[0,0];return f.top>n-c?u[1]=-1:f.top+f.height<n+c&&(u[1]=1),f.left>r-c?u[0]=-1:f.left+f.width<r+c&&(u[0]=1),!(!u[0]&&!u[1])&&(this.prevDirection=u,this.prevPos=p({container:o,direction:u}),this.trigger("scroll",{container:o,direction:u,inputEvent:t}),!0)},i.dragAfter=function(t,e){var r=this.prevPos,n=this.prevDirection;if(!this.prevDirection)return!1;var o=e.container,i=e.getScrollPosition,c=(void 0===i?l:i)({container:o,direction:n}),s=c[0]-r[0],p=c[1]-r[1];return!(!s&&!p)&&(this.trigger("move",{offsetX:n[0]?s:0,offsetY:n[1]?p:0,inputEvent:t}),!0)},o}(t)}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component")):"function"==typeof define&&define.amd?define(["@egjs/component"],e):(t=t||self).DragScroll=e(t.Component)}(this,function(t){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function a(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}return function(e){function t(){this.constructor=r}var r,o;function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.prevDirection=null,t.startPos=[],t.prevPos=[],t}c(r=n,o=e),r.prototype=null===o?Object.create(o):(t.prototype=o.prototype,new t);var i=n.prototype;return i.dragStart=function(t,e){var r=e.getBoundingClientRect(),o=r.top,n=r.left,i=r.width,c=r.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:o,left:n,width:i,height:c}},i.drag=function(t,e){var r=t.clientX,o=t.clientY;this.prevDirection=null;var n=e.container,i=e.threshold,c=void 0===i?0:i,s=e.getScrollPosition,p=void 0===s?a:s,l=this.startRect,f=this.startPos,u=[0,0];return l.top>o-c?(f[1]>l.top||o<f[1])&&(u[1]=-1):l.top+l.height<o+c&&(f[1]<l.top+l.height||o>f[1])&&(u[1]=1),l.left>r-c?(f[0]>l.left||r<f[0])&&(u[0]=-1):l.left+l.width<r+c&&(f[0]<l.left+l.width||r>f[0])&&(u[0]=1),!(!u[0]&&!u[1])&&(this.prevDirection=u,this.prevPos=p({container:n,direction:u}),this.trigger("scroll",{container:n,direction:u,inputEvent:t}),!0)},i.dragAfter=function(t,e){var r=this.prevPos,o=this.prevDirection;if(!this.prevDirection)return!1;var n=e.container,i=e.getScrollPosition,c=(void 0===i?a:i)({container:n,direction:o}),s=c[0]-r[0],p=c[1]-r[1];return!(!s&&!p)&&(this.trigger("move",{offsetX:o[0]?s:0,offsetY:o[1]?p:0,inputEvent:t}),!0)},n}(t)}); | ||
//# sourceMappingURL=dragscroll.min.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
@@ -359,2 +359,3 @@ (function (global, factory) { | ||
_this.prevDirection = null; | ||
_this.startPos = []; | ||
_this.prevPos = []; | ||
@@ -366,3 +367,3 @@ return _this; | ||
__proto.dragStart = function (container) { | ||
__proto.dragStart = function (e, container) { | ||
var _a = container.getBoundingClientRect(), | ||
@@ -374,2 +375,3 @@ top = _a.top, | ||
this.startPos = [e.clientX, e.clientY]; | ||
this.startRect = { | ||
@@ -392,15 +394,27 @@ top: top, | ||
getScrollPosition = _b === void 0 ? getDefaultScrollPosition : _b; | ||
var startRect = this.startRect; | ||
var _c = this, | ||
startRect = _c.startRect, | ||
startPos = _c.startPos; | ||
var direction = [0, 0]; | ||
if (startRect.top > clientY - threshold) { | ||
direction[1] = -1; | ||
if (startPos[1] > startRect.top || clientY < startPos[1]) { | ||
direction[1] = -1; | ||
} | ||
} else if (startRect.top + startRect.height < clientY + threshold) { | ||
direction[1] = 1; | ||
if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { | ||
direction[1] = 1; | ||
} | ||
} | ||
if (startRect.left > clientX - threshold) { | ||
direction[0] = -1; | ||
if (startPos[0] > startRect.left || clientX < startPos[0]) { | ||
direction[0] = -1; | ||
} | ||
} else if (startRect.left + startRect.width < clientX + threshold) { | ||
direction[0] = 1; | ||
if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { | ||
direction[0] = 1; | ||
} | ||
} | ||
@@ -407,0 +421,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/dragscroll.git | ||
version: 0.0.6 | ||
version: 0.1.0 | ||
*/ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).DragScroll=n()}(this,function(){"use strict";var f=function(t,n){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(t,n)};function c(t){return void 0===t}function h(t){var n=t.container;return[n.scrollLeft,n.scrollTop]}return function(n){function t(){this.constructor=r}var r,e;function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.startRect=null,t.prevDirection=null,t.prevPos=[],t}f(r=i,e=n),r.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t);var o=i.prototype;return o.dragStart=function(t){var n=t.getBoundingClientRect(),r=n.top,e=n.left,i=n.width,o=n.height;this.startRect={top:r,left:e,width:i,height:o}},o.drag=function(t,n){var r=t.clientX,e=t.clientY;this.prevDirection=null;var i=n.container,o=n.threshold,f=void 0===o?0:o,c=n.getScrollPosition,s=void 0===c?h:c,u=this.startRect,a=[0,0];return u.top>e-f?a[1]=-1:u.top+u.height<e+f&&(a[1]=1),u.left>r-f?a[0]=-1:u.left+u.width<r+f&&(a[0]=1),!(!a[0]&&!a[1])&&(this.prevDirection=a,this.prevPos=s({container:i,direction:a}),this.trigger("scroll",{container:i,direction:a,inputEvent:t}),!0)},o.dragAfter=function(t,n){var r=this.prevPos,e=this.prevDirection;if(!this.prevDirection)return!1;var i=n.container,o=n.getScrollPosition,f=(void 0===o?h:o)({container:i,direction:e}),c=f[0]-r[0],s=f[1]-r[1];return!(!c&&!s)&&(this.trigger("move",{offsetX:e[0]?c:0,offsetY:e[1]?s:0,inputEvent:t}),!0)},i}(function(){var t=function(){function t(){this._eventHandler={},this.options={}}var n=t.prototype;return n.trigger=function(t,n){void 0===n&&(n={});var r=this._eventHandler[t]||[];if(!(0<r.length))return!0;r=r.concat(),n.eventType=t;var e=!1,i=[n],o=0;n.stop=function(){e=!0},n.currentTarget=this;for(var f=arguments.length,c=new Array(2<f?f-2:0),s=2;s<f;s++)c[s-2]=arguments[s];for(1<=c.length&&(i=i.concat(c)),o=0;r[o];o++)r[o].apply(this,i);return!e},n.once=function(i,o){if("object"==typeof i&&c(o)){var t,n=i;for(t in n)this.once(t,n[t]);return this}if("string"==typeof i&&"function"==typeof o){var f=this;this.on(i,function t(){for(var n=arguments.length,r=new Array(n),e=0;e<n;e++)r[e]=arguments[e];o.apply(f,r),f.off(i,t)})}return this},n.hasOn=function(t){return!!this._eventHandler[t]},n.on=function(t,n){if("object"==typeof t&&c(n)){var r,e=t;for(r in e)this.on(r,e[r]);return this}if("string"==typeof t&&"function"==typeof n){var i=this._eventHandler[t];c(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(n)}return this},n.off=function(t,n){if(c(t))return this._eventHandler={},this;if(c(n)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var r,e=t;for(r in e)this.off(r,e[r]);return this}var i,o,f=this._eventHandler[t];if(f)for(i=0;void 0!==(o=f[i]);i++)if(o===n){f=f.splice(i,1);break}return this},t}();return t.VERSION="2.1.2",t}())}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).DragScroll=n()}(this,function(){"use strict";var f=function(t,n){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function s(t){return void 0===t}function l(t){var n=t.container;return[n.scrollLeft,n.scrollTop]}return function(n){function t(){this.constructor=e}var e,r;function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.startRect=null,t.prevDirection=null,t.startPos=[],t.prevPos=[],t}f(e=i,r=n),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.dragStart=function(t,n){var e=n.getBoundingClientRect(),r=e.top,i=e.left,o=e.width,f=e.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:r,left:i,width:o,height:f}},o.drag=function(t,n){var e=t.clientX,r=t.clientY;this.prevDirection=null;var i=n.container,o=n.threshold,f=void 0===o?0:o,s=n.getScrollPosition,c=void 0===s?l:s,a=this.startRect,u=this.startPos,h=[0,0];return a.top>r-f?(u[1]>a.top||r<u[1])&&(h[1]=-1):a.top+a.height<r+f&&(u[1]<a.top+a.height||r>u[1])&&(h[1]=1),a.left>e-f?(u[0]>a.left||e<u[0])&&(h[0]=-1):a.left+a.width<e+f&&(u[0]<a.left+a.width||e>u[0])&&(h[0]=1),!(!h[0]&&!h[1])&&(this.prevDirection=h,this.prevPos=c({container:i,direction:h}),this.trigger("scroll",{container:i,direction:h,inputEvent:t}),!0)},o.dragAfter=function(t,n){var e=this.prevPos,r=this.prevDirection;if(!this.prevDirection)return!1;var i=n.container,o=n.getScrollPosition,f=(void 0===o?l:o)({container:i,direction:r}),s=f[0]-e[0],c=f[1]-e[1];return!(!s&&!c)&&(this.trigger("move",{offsetX:r[0]?s:0,offsetY:r[1]?c:0,inputEvent:t}),!0)},i}(function(){var t=function(){function t(){this._eventHandler={},this.options={}}var n=t.prototype;return n.trigger=function(t,n){void 0===n&&(n={});var e=this._eventHandler[t]||[];if(!(0<e.length))return!0;e=e.concat(),n.eventType=t;var r=!1,i=[n],o=0;n.stop=function(){r=!0},n.currentTarget=this;for(var f=arguments.length,s=new Array(2<f?f-2:0),c=2;c<f;c++)s[c-2]=arguments[c];for(1<=s.length&&(i=i.concat(s)),o=0;e[o];o++)e[o].apply(this,i);return!r},n.once=function(i,o){if("object"==typeof i&&s(o)){var t,n=i;for(t in n)this.once(t,n[t]);return this}if("string"==typeof i&&"function"==typeof o){var f=this;this.on(i,function t(){for(var n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];o.apply(f,e),f.off(i,t)})}return this},n.hasOn=function(t){return!!this._eventHandler[t]},n.on=function(t,n){if("object"==typeof t&&s(n)){var e,r=t;for(e in r)this.on(e,r[e]);return this}if("string"==typeof t&&"function"==typeof n){var i=this._eventHandler[t];s(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(n)}return this},n.off=function(t,n){if(s(t))return this._eventHandler={},this;if(s(n)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var e,r=t;for(e in r)this.off(e,r[e]);return this}var i,o,f=this._eventHandler[t];if(f)for(i=0;void 0!==(o=f[i]);i++)if(o===n){f=f.splice(i,1);break}return this},t}();return t.VERSION="2.1.2",t}())}); | ||
//# sourceMappingURL=dragscroll.pkgd.min.js.map |
{ | ||
"name": "@scena/dragscroll", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/dragscroll.cjs.js", |
@@ -16,4 +16,5 @@ import Component from "@egjs/component"; | ||
private prevDirection: number[] | null = null; | ||
private startPos: number[] = []; | ||
private prevPos: number[] = []; | ||
public dragStart(container: HTMLElement) { | ||
public dragStart(e: any, container: HTMLElement) { | ||
const { | ||
@@ -26,2 +27,3 @@ top, | ||
this.startPos = [e.clientX, e.clientY]; | ||
this.startRect = { top, left, width, height }; | ||
@@ -43,2 +45,3 @@ } | ||
startRect, | ||
startPos, | ||
} = this; | ||
@@ -49,10 +52,18 @@ | ||
if (startRect.top > clientY - threshold) { | ||
direction[1] = -1; | ||
if (startPos[1] > startRect.top || clientY < startPos[1]) { | ||
direction[1] = -1; | ||
} | ||
} else if (startRect.top + startRect.height < clientY + threshold) { | ||
direction[1] = 1; | ||
if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { | ||
direction[1] = 1; | ||
} | ||
} | ||
if (startRect.left > clientX - threshold) { | ||
direction[0] = -1; | ||
if (startPos[0] > startRect.left || clientX < startPos[0]) { | ||
direction[0] = -1; | ||
} | ||
} else if (startRect.left + startRect.width < clientX + threshold) { | ||
direction[0] = 1; | ||
if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { | ||
direction[0] = 1; | ||
} | ||
} | ||
@@ -59,0 +70,0 @@ if (!direction[0] && !direction[1]) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
82853
1180