src/Draggable/Plugins/Mirror/Mirror.js
function positionMirror({withFrame = false, initial = false} = {}) {
  return ({mirror, sensorEvent, mirrorOffset, initialY, initialX, scrollOffset, options, ...args}) => {
    return withPromise(
      (resolve) => {
        const result = {
          mirror,
          sensorEvent,
          mirrorOffset,
          options,
          ...args,
        };

        if (mirrorOffset) {
          const x = sensorEvent.clientX - mirrorOffset.left - scrollOffset.x;
          const y = sensorEvent.clientY - mirrorOffset.top - scrollOffset.y;

          if ((options.xAxis && options.yAxis) || initial) {
            mirror.style.transform = `translate3d(${x}px, ${y}px, 0)`;
          } else if (options.xAxis && !options.yAxis) {
            mirror.style.transform = `translate3d(${x}px, ${initialY}px, 0)`;
          } else if (options.yAxis && !options.xAxis) {
            mirror.style.transform = `translate3d(${initialX}px, ${y}px, 0)`;
          }

          if (initial) {
            result.initialX = x;
            result.initialY = y;
          }
        }

        resolve(result);
      },
      {frame: withFrame},
    );
  };
}
function positionMirror({withFrame = false, initial = false} = {}) {
  return ({mirror, sensorEvent, mirrorOffset, initialY, initialX, scrollOffset, options, ...args}) => {
    return withPromise(
      (resolve) => {
        const result = {
          mirror,
          sensorEvent,
          mirrorOffset,
          options,
          ...args,
        };

        if (mirrorOffset) {
          const x = sensorEvent.clientX - mirrorOffset.left - scrollOffset.x;
          const y = sensorEvent.clientY - mirrorOffset.top - scrollOffset.y;

          if ((options.xAxis && options.yAxis) || initial) {
            mirror.style.transform = `translate3d(${x}px, ${y}px, 0)`;
          } else if (options.xAxis && !options.yAxis) {
            mirror.style.transform = `translate3d(${x}px, ${initialY}px, 0)`;
          } else if (options.yAxis && !options.xAxis) {
            mirror.style.transform = `translate3d(${initialX}px, ${y}px, 0)`;
          }

          if (initial) {
            result.initialX = x;
            result.initialY = y;
          }
        }

        resolve(result);
      },
      {frame: withFrame},
    );
  };
}
function positionMirror ( { withFrame = false , initial = false } = { } ) { return ( { mirror , sensorEvent , mirrorOffset , initialY , initialX , scrollOffset , options , ... args } ) => { return withPromise ( ( resolve ) => { const result = { mirror , sensorEvent , mirrorOffset , options , ... args , } ; if ( mirrorOffset ) { const x = sensorEvent . clientX - mirrorOffset . left - scrollOffset . x ; const y = sensorEvent . clientY - mirrorOffset . top - scrollOffset . y ; if ( ( options . xAxis && options . yAxis ) || initial ) { mirror . style . transform = ` ${ x } ${ y } ` ; } else if ( options . xAxis && ! options . yAxis ) { mirror . style . transform = ` ${ x } ${ initialY } ` ; } else if ( options . yAxis && ! options . xAxis ) { mirror . style . transform = ` ${ initialX } ${ y } ` ; } if ( initial ) { result . initialX = x ; result . initialY = y ; } } resolve ( result ) ; } , { frame : withFrame } , ) ; } ; }
Positions mirror with translate3d
@param {Object} state
@param {HTMLElement} state.mirror
@param {SensorEvent} state.sensorEvent
@param {Object} state.mirrorOffset
@param {Number} state.initialY
@param {Number} state.initialX
@param {Object} state.options
@return {Promise}
@private
Positions mirror with translate3d