Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@odopod/odo-draggable

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@odopod/odo-draggable - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

dist/odo-draggable.esm.js

32

dist/odo-draggable.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tiny-emitter'), require('@odopod/odo-device'), require('@odopod/odo-pointer'), require('@odopod/odo-helpers')) :
typeof define === 'function' && define.amd ? define(['tiny-emitter', '@odopod/odo-device', '@odopod/odo-pointer', '@odopod/odo-helpers'], factory) :
(global.OdoDraggable = factory(global.TinyEmitter,global.OdoDevice,global.OdoPointer,global.OdoHelpers));
}(this, (function (TinyEmitter,OdoDevice,OdoPointer,odoHelpers) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@odopod/odo-pointer'), require('tiny-emitter'), require('@odopod/odo-device'), require('@odopod/odo-helpers')) :
typeof define === 'function' && define.amd ? define(['@odopod/odo-pointer', 'tiny-emitter', '@odopod/odo-device', '@odopod/odo-helpers'], factory) :
(global.OdoDraggable = factory(global.OdoPointer,global.TinyEmitter,global.OdoDevice,global.OdoHelpers));
}(this, (function (OdoPointer,TinyEmitter,OdoDevice,odoHelpers) { 'use strict';
OdoPointer = OdoPointer && OdoPointer.hasOwnProperty('default') ? OdoPointer['default'] : OdoPointer;
TinyEmitter = TinyEmitter && TinyEmitter.hasOwnProperty('default') ? TinyEmitter['default'] : TinyEmitter;
OdoDevice = OdoDevice && OdoDevice.hasOwnProperty('default') ? OdoDevice['default'] : OdoDevice;
OdoPointer = OdoPointer && OdoPointer.hasOwnProperty('default') ? OdoPointer['default'] : OdoPointer;

@@ -207,5 +207,5 @@ var settings = {

* Limits of how far the draggable element can be dragged.
* @type {math.Rect}
* @type {Rect}
*/
_this.limits = new odoHelpers.math.Rect(NaN, NaN, NaN, NaN);
_this.limits = new odoHelpers.Rect(NaN, NaN, NaN, NaN);

@@ -240,3 +240,3 @@ _this.pointer = new OdoPointer(element, {

Draggable.prototype._saveDimensions = function _saveDimensions() {
this._container = odoHelpers.style.getSize(this.element);
this._container = odoHelpers.getSize(this.element);
ensureObjectHasSize(this._container);

@@ -278,4 +278,4 @@ this._relativeZero = this._getRelativeZero();

var containmentRect = this._parentEl.getBoundingClientRect();
var paddings = odoHelpers.style.getPaddingBox(this._parentEl);
var margins = odoHelpers.style.getMarginBox(this.element);
var paddings = odoHelpers.getPaddingBox(this._parentEl);
var margins = odoHelpers.getMarginBox(this.element);
var offsetCorrectionX = margins.left + paddings.left + containmentRect.left;

@@ -310,7 +310,7 @@ var offsetCorrectionY = margins.top + paddings.top + containmentRect.top;

Draggable._limitValue = function _limitValue(value, rectPosition, rectSize) {
var side = odoHelpers.utilities.defaultsTo(rectPosition, null, !Number.isNaN(rectPosition));
var dimension = odoHelpers.utilities.defaultsTo(rectSize, 0, !Number.isNaN(rectSize));
var max = odoHelpers.utilities.defaultsTo(side + dimension, Infinity, side !== null);
var min = odoHelpers.utilities.defaultsTo(side, -Infinity, side !== null);
return odoHelpers.math.clamp(value, min, max);
var side = odoHelpers.defaultsTo(rectPosition, null, !Number.isNaN(rectPosition));
var dimension = odoHelpers.defaultsTo(rectSize, 0, !Number.isNaN(rectSize));
var max = odoHelpers.defaultsTo(side + dimension, Infinity, side !== null);
var min = odoHelpers.defaultsTo(side, -Infinity, side !== null);
return odoHelpers.clamp(value, min, max);
};

@@ -596,3 +596,3 @@

* Sets (or reset) the Drag limits after a Dragger is created.
* @param {math.Rect} limits Object containing left, top, width,
* @param {Rect} limits Object containing left, top, width,
* height for new Dragger limits.

@@ -599,0 +599,0 @@ */

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("tiny-emitter"),require("@odopod/odo-device"),require("@odopod/odo-pointer"),require("@odopod/odo-helpers")):"function"==typeof define&&define.amd?define(["tiny-emitter","@odopod/odo-device","@odopod/odo-pointer","@odopod/odo-helpers"],e):t.OdoDraggable=e(t.TinyEmitter,t.OdoDevice,t.OdoPointer,t.OdoHelpers)}(this,function(t,e,i,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;var n={EventType:{START:"ododraggable:start",MOVE:"ododraggable:move",END:"ododraggable:end",SETTLE:"ododraggable:throwsettle"},Classes:{GRABBABLE:"grabbable",GRABBING:"grabbing"},Defaults:{axis:(i=i&&i.hasOwnProperty("default")?i.default:i).Axis.X,amplifier:24,velocityStop:.08,throwFriction:.94,isThrowable:!1}},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),a=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e};function h(t,e){if(!t)throw new Error(e)}var l=function(t){function l(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,l);var s=a(this,t.call(this));return s.element=e,s.options=Object.assign({},l.Defaults,n),s._parentEl=e.parentNode,s._currentPosition=new o.Coordinate,s._relativeZero=new o.Coordinate,s._throwVelocity=new o.Coordinate,s._delta=new o.Coordinate,s._requestId=0,s._container={width:0,height:0},s.limits=new o.math.Rect(NaN,NaN,NaN,NaN),s.pointer=new i(e,{axis:s.options.axis}),s.element.classList.add(l.Classes.GRABBABLE),s._listen(),s}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(l,t),l.prototype._listen=function(){this._onStart=this._handleDragStart.bind(this),this._onMove=this._handleDragMove.bind(this),this._onEnd=this._handleDragEnd.bind(this),this.pointer.on(i.EventType.START,this._onStart),this.pointer.on(i.EventType.MOVE,this._onMove),this.pointer.on(i.EventType.END,this._onEnd)},l.prototype._saveDimensions=function(){var t;this._container=o.style.getSize(this.element),h((t=this._container).width>0,"containing element's width is zero"),h(t.height>0,"containing element's height is zero"),this._relativeZero=this._getRelativeZero()},l.prototype._getRelativeZero=function(){return o.Coordinate.difference(this._getDraggablePosition(),this._getOffsetCorrection())},l.prototype._getDraggablePosition=function(){var t=this.element.getBoundingClientRect();return new o.Coordinate(t.left,t.top)},l.prototype._getOffsetCorrection=function(){var t=this._parentEl.getBoundingClientRect(),e=o.style.getPaddingBox(this._parentEl),i=o.style.getMarginBox(this.element),n=i.left+e.left+t.left,r=i.top+e.top+t.top;return new o.Coordinate(n,r)},l.prototype._setCurrentPosition=function(t){this.pointer.applyFriction(t);var e=this._limitX(t.x/100*this._parentEl.offsetWidth),i=this._limitY(t.y/100*this._parentEl.offsetHeight);this._currentPosition=this._getAxisCoordinate(Math.round(e),Math.round(i))},l._limitValue=function(t,e,i){var n=o.utilities.defaultsTo(e,null,!Number.isNaN(e)),r=o.utilities.defaultsTo(i,0,!Number.isNaN(i)),s=o.utilities.defaultsTo(n+r,1/0,null!==n),a=o.utilities.defaultsTo(n,-1/0,null!==n);return o.math.clamp(t,a,s)},l.prototype._limitX=function(t){return l._limitValue(t,this.limits.left,this.limits.width)},l.prototype._limitY=function(t){return l._limitValue(t,this.limits.top,this.limits.height)},l.prototype._getElementPosition=function(t){t&&this._setCurrentPosition(t);var e=this._currentPosition.x/this._container.width*100,i=this._currentPosition.y/this._container.height*100;return this._getAxisCoordinate(e,i)},l.prototype._getAxisCoordinate=function(t,e){return this.pointer.isXAxis()?new o.Coordinate(t,0):this.pointer.isYAxis()?new o.Coordinate(0,e):new o.Coordinate(t,e)},l.prototype._getNewLimitedPosition=function(t){var e=o.Coordinate.sum(this._relativeZero,t);return new o.Coordinate(this._limitX(e.x),this._limitY(e.y))},l.prototype._handleDragStart=function(t){this._stopThrow(),this._saveDimensions(),this._currentPosition=this._relativeZero,this._emitEvent(this._createEvent(l.EventType.START,t)),this.element.classList.add(l.Classes.GRABBING)},l.prototype._handleDragMove=function(t){this._currentPosition=this._getNewLimitedPosition(this.pointer.delta),this._emitEvent(this._createEvent(l.EventType.MOVE,t)),this.pointer._isDeactivated||this._applyPosition()},l.prototype._handleDragEnd=function(t){this._emitEvent(this._createEvent(l.EventType.END,t)),this.element.classList.remove(l.Classes.GRABBING),this.options.isThrowable&&this.pointer.hasVelocity(t.currentVelocity,0)&&this._throw(t.currentVelocity,t.delta)},l.prototype._throw=function(t,e){this._delta=e,this._throwVelocity=o.Coordinate.scale(t,this.options.amplifier),this._animateThrow()},l.prototype._animateThrow=function(){this.pointer.hasVelocity(this._throwVelocity,this.options.velocityStop)?(this._currentPosition=this._getNewLimitedPosition(this._delta),this._applyPosition(),this._delta.translate(this._throwVelocity),this._throwVelocity.scale(this.options.throwFriction),this._requestId=requestAnimationFrame(this._animateThrow.bind(this))):(this._currentPosition.x=Math.round(this._currentPosition.x),this._currentPosition.y=Math.round(this._currentPosition.y),this._applyPosition(),this._emitSettled())},l.prototype._stopThrow=function(){this._delta=new o.Coordinate,this._throwVelocity=new o.Coordinate,cancelAnimationFrame(this._requestId)},l.prototype._emitSettled=function(){this._emitEvent(new i.Event({type:l.EventType.SETTLE,target:this.element,axis:this.pointer.axis,deltaTime:Date.now()-this.pointer.startTime,delta:o.Coordinate.difference(this._relativeZero,this._currentPosition),start:this._relativeZero,end:this._currentPosition,currentVelocity:this._throwVelocity,position:{pixel:this.getPosition(),percent:this.getPosition(!0)}}))},l.prototype._createEvent=function(t,e){return new i.Event({type:t,target:e.target,currentTarget:this.element,axis:this.pointer.axis,deltaTime:this.pointer.deltaTime,delta:o.Coordinate.difference(this._currentPosition,this._relativeZero),start:this._relativeZero,end:this._currentPosition,currentVelocity:this.pointer.velocity,position:{pixel:this.getPosition(),percent:this.getPosition(!0)}})},l.prototype._applyPosition=function(t){var i=this._getElementPosition(t);return this.element.style[e.Dom.TRANSFORM]="translate("+i.x+"%,"+i.y+"%)",this._currentPosition},l.prototype.getPosition=function(t){return t?new o.Coordinate(this._currentPosition.x/this._parentEl.offsetWidth*100,this._currentPosition.y/this._parentEl.offsetHeight*100):this._currentPosition},l.prototype.setPosition=function(t,e){return this.update(),this._applyPosition(new o.Coordinate(t,e))},l.prototype.setLimits=function(t){this.limits=t},l.prototype.update=function(){this._saveDimensions()},l.prototype.dispose=function(){this.pointer.off(i.EventType.START,this._onStart),this.pointer.off(i.EventType.MOVE,this._onMove),this.pointer.off(i.EventType.END,this._onEnd),this.pointer.dispose(),this.element.classList.remove(l.Classes.GRABBABLE),this._parentEl=null,this.element=null},l.prototype._emitEvent=function(t){return this.emit(t.type,t),t.defaultPrevented},s(l,[{key:"friction",get:function(){return this.pointer.friction},set:function(t){this.pointer.friction=t}},{key:"isEnabled",get:function(){return this.pointer.isEnabled},set:function(t){this.pointer.isEnabled=t,this.element.classList.toggle(n.Classes.GRABBABLE,t)}}]),l}(t);return Object.assign(l,n),l});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@odopod/odo-pointer"),require("tiny-emitter"),require("@odopod/odo-device"),require("@odopod/odo-helpers")):"function"==typeof define&&define.amd?define(["@odopod/odo-pointer","tiny-emitter","@odopod/odo-device","@odopod/odo-helpers"],e):t.OdoDraggable=e(t.OdoPointer,t.TinyEmitter,t.OdoDevice,t.OdoHelpers)}(this,function(t,e,i,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,i=i&&i.hasOwnProperty("default")?i.default:i;var n={EventType:{START:"ododraggable:start",MOVE:"ododraggable:move",END:"ododraggable:end",SETTLE:"ododraggable:throwsettle"},Classes:{GRABBABLE:"grabbable",GRABBING:"grabbing"},Defaults:{axis:t.Axis.X,amplifier:24,velocityStop:.08,throwFriction:.94,isThrowable:!1}},r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),a=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e};function h(t,e){if(!t)throw new Error(e)}var l=function(e){function l(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,l);var s=a(this,e.call(this));return s.element=i,s.options=Object.assign({},l.Defaults,n),s._parentEl=i.parentNode,s._currentPosition=new o.Coordinate,s._relativeZero=new o.Coordinate,s._throwVelocity=new o.Coordinate,s._delta=new o.Coordinate,s._requestId=0,s._container={width:0,height:0},s.limits=new o.Rect(NaN,NaN,NaN,NaN),s.pointer=new t(i,{axis:s.options.axis}),s.element.classList.add(l.Classes.GRABBABLE),s._listen(),s}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(l,e),l.prototype._listen=function(){this._onStart=this._handleDragStart.bind(this),this._onMove=this._handleDragMove.bind(this),this._onEnd=this._handleDragEnd.bind(this),this.pointer.on(t.EventType.START,this._onStart),this.pointer.on(t.EventType.MOVE,this._onMove),this.pointer.on(t.EventType.END,this._onEnd)},l.prototype._saveDimensions=function(){var t;this._container=o.getSize(this.element),h((t=this._container).width>0,"containing element's width is zero"),h(t.height>0,"containing element's height is zero"),this._relativeZero=this._getRelativeZero()},l.prototype._getRelativeZero=function(){return o.Coordinate.difference(this._getDraggablePosition(),this._getOffsetCorrection())},l.prototype._getDraggablePosition=function(){var t=this.element.getBoundingClientRect();return new o.Coordinate(t.left,t.top)},l.prototype._getOffsetCorrection=function(){var t=this._parentEl.getBoundingClientRect(),e=o.getPaddingBox(this._parentEl),i=o.getMarginBox(this.element),n=i.left+e.left+t.left,r=i.top+e.top+t.top;return new o.Coordinate(n,r)},l.prototype._setCurrentPosition=function(t){this.pointer.applyFriction(t);var e=this._limitX(t.x/100*this._parentEl.offsetWidth),i=this._limitY(t.y/100*this._parentEl.offsetHeight);this._currentPosition=this._getAxisCoordinate(Math.round(e),Math.round(i))},l._limitValue=function(t,e,i){var n=o.defaultsTo(e,null,!Number.isNaN(e)),r=o.defaultsTo(i,0,!Number.isNaN(i)),s=o.defaultsTo(n+r,1/0,null!==n),a=o.defaultsTo(n,-1/0,null!==n);return o.clamp(t,a,s)},l.prototype._limitX=function(t){return l._limitValue(t,this.limits.left,this.limits.width)},l.prototype._limitY=function(t){return l._limitValue(t,this.limits.top,this.limits.height)},l.prototype._getElementPosition=function(t){t&&this._setCurrentPosition(t);var e=this._currentPosition.x/this._container.width*100,i=this._currentPosition.y/this._container.height*100;return this._getAxisCoordinate(e,i)},l.prototype._getAxisCoordinate=function(t,e){return this.pointer.isXAxis()?new o.Coordinate(t,0):this.pointer.isYAxis()?new o.Coordinate(0,e):new o.Coordinate(t,e)},l.prototype._getNewLimitedPosition=function(t){var e=o.Coordinate.sum(this._relativeZero,t);return new o.Coordinate(this._limitX(e.x),this._limitY(e.y))},l.prototype._handleDragStart=function(t){this._stopThrow(),this._saveDimensions(),this._currentPosition=this._relativeZero,this._emitEvent(this._createEvent(l.EventType.START,t)),this.element.classList.add(l.Classes.GRABBING)},l.prototype._handleDragMove=function(t){this._currentPosition=this._getNewLimitedPosition(this.pointer.delta),this._emitEvent(this._createEvent(l.EventType.MOVE,t)),this.pointer._isDeactivated||this._applyPosition()},l.prototype._handleDragEnd=function(t){this._emitEvent(this._createEvent(l.EventType.END,t)),this.element.classList.remove(l.Classes.GRABBING),this.options.isThrowable&&this.pointer.hasVelocity(t.currentVelocity,0)&&this._throw(t.currentVelocity,t.delta)},l.prototype._throw=function(t,e){this._delta=e,this._throwVelocity=o.Coordinate.scale(t,this.options.amplifier),this._animateThrow()},l.prototype._animateThrow=function(){this.pointer.hasVelocity(this._throwVelocity,this.options.velocityStop)?(this._currentPosition=this._getNewLimitedPosition(this._delta),this._applyPosition(),this._delta.translate(this._throwVelocity),this._throwVelocity.scale(this.options.throwFriction),this._requestId=requestAnimationFrame(this._animateThrow.bind(this))):(this._currentPosition.x=Math.round(this._currentPosition.x),this._currentPosition.y=Math.round(this._currentPosition.y),this._applyPosition(),this._emitSettled())},l.prototype._stopThrow=function(){this._delta=new o.Coordinate,this._throwVelocity=new o.Coordinate,cancelAnimationFrame(this._requestId)},l.prototype._emitSettled=function(){this._emitEvent(new t.Event({type:l.EventType.SETTLE,target:this.element,axis:this.pointer.axis,deltaTime:Date.now()-this.pointer.startTime,delta:o.Coordinate.difference(this._relativeZero,this._currentPosition),start:this._relativeZero,end:this._currentPosition,currentVelocity:this._throwVelocity,position:{pixel:this.getPosition(),percent:this.getPosition(!0)}}))},l.prototype._createEvent=function(e,i){return new t.Event({type:e,target:i.target,currentTarget:this.element,axis:this.pointer.axis,deltaTime:this.pointer.deltaTime,delta:o.Coordinate.difference(this._currentPosition,this._relativeZero),start:this._relativeZero,end:this._currentPosition,currentVelocity:this.pointer.velocity,position:{pixel:this.getPosition(),percent:this.getPosition(!0)}})},l.prototype._applyPosition=function(t){var e=this._getElementPosition(t);return this.element.style[i.Dom.TRANSFORM]="translate("+e.x+"%,"+e.y+"%)",this._currentPosition},l.prototype.getPosition=function(t){return t?new o.Coordinate(this._currentPosition.x/this._parentEl.offsetWidth*100,this._currentPosition.y/this._parentEl.offsetHeight*100):this._currentPosition},l.prototype.setPosition=function(t,e){return this.update(),this._applyPosition(new o.Coordinate(t,e))},l.prototype.setLimits=function(t){this.limits=t},l.prototype.update=function(){this._saveDimensions()},l.prototype.dispose=function(){this.pointer.off(t.EventType.START,this._onStart),this.pointer.off(t.EventType.MOVE,this._onMove),this.pointer.off(t.EventType.END,this._onEnd),this.pointer.dispose(),this.element.classList.remove(l.Classes.GRABBABLE),this._parentEl=null,this.element=null},l.prototype._emitEvent=function(t){return this.emit(t.type,t),t.defaultPrevented},s(l,[{key:"friction",get:function(){return this.pointer.friction},set:function(t){this.pointer.friction=t}},{key:"isEnabled",get:function(){return this.pointer.isEnabled},set:function(t){this.pointer.isEnabled=t,this.element.classList.toggle(n.Classes.GRABBABLE,t)}}]),l}(e);return Object.assign(l,n),l});
//# sourceMappingURL=odo-draggable.min.js.map
{
"name": "@odopod/odo-draggable",
"description": "A class for versatile, performant draggability.",
"version": "1.0.4",
"version": "1.1.0",
"main": "dist/odo-draggable.js",
"module": "dist/odo-draggable.esm.js",
"odoModule": "src/draggable.js",
"sideEffects": false,
"author": "Odopod",

@@ -15,5 +17,5 @@ "contributors": [

"dependencies": {
"@odopod/odo-device": "^1.0.3",
"@odopod/odo-helpers": "^1.0.3",
"@odopod/odo-pointer": "^1.0.3",
"@odopod/odo-device": "^1.1.0",
"@odopod/odo-helpers": "^2.0.0",
"@odopod/odo-pointer": "^1.1.0",
"tiny-emitter": "^2.0.1"

@@ -25,4 +27,3 @@ },

"dist",
"src",
"index.js"
"src"
],

@@ -29,0 +30,0 @@ "odoKeywords": [

import TinyEmitter from 'tiny-emitter';
import OdoDevice from '@odopod/odo-device';
import OdoPointer from '@odopod/odo-pointer';
import { Coordinate, utilities, math, style } from '@odopod/odo-helpers';
import {
clamp,
Coordinate,
defaultsTo,
getMarginBox,
getPaddingBox,
getSize,
Rect,
} from '@odopod/odo-helpers';
import settings from './settings';

@@ -98,5 +106,5 @@

* Limits of how far the draggable element can be dragged.
* @type {math.Rect}
* @type {Rect}
*/
this.limits = new math.Rect(NaN, NaN, NaN, NaN);
this.limits = new Rect(NaN, NaN, NaN, NaN);

@@ -128,3 +136,3 @@ this.pointer = new OdoPointer(element, {

_saveDimensions() {
this._container = style.getSize(this.element);
this._container = getSize(this.element);
ensureObjectHasSize(this._container);

@@ -165,4 +173,4 @@ this._relativeZero = this._getRelativeZero();

const containmentRect = this._parentEl.getBoundingClientRect();
const paddings = style.getPaddingBox(this._parentEl);
const margins = style.getMarginBox(this.element);
const paddings = getPaddingBox(this._parentEl);
const margins = getMarginBox(this.element);
const offsetCorrectionX = margins.left + paddings.left + containmentRect.left;

@@ -193,7 +201,7 @@ const offsetCorrectionY = margins.top + paddings.top + containmentRect.top;

static _limitValue(value, rectPosition, rectSize) {
const side = utilities.defaultsTo(rectPosition, null, !Number.isNaN(rectPosition));
const dimension = utilities.defaultsTo(rectSize, 0, !Number.isNaN(rectSize));
const max = utilities.defaultsTo(side + dimension, Infinity, side !== null);
const min = utilities.defaultsTo(side, -Infinity, side !== null);
return math.clamp(value, min, max);
const side = defaultsTo(rectPosition, null, !Number.isNaN(rectPosition));
const dimension = defaultsTo(rectSize, 0, !Number.isNaN(rectSize));
const max = defaultsTo(side + dimension, Infinity, side !== null);
const min = defaultsTo(side, -Infinity, side !== null);
return clamp(value, min, max);
}

@@ -450,3 +458,3 @@

* Sets (or reset) the Drag limits after a Dragger is created.
* @param {math.Rect} limits Object containing left, top, width,
* @param {Rect} limits Object containing left, top, width,
* height for new Dragger limits.

@@ -453,0 +461,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc