react-filerobot-video-editor
Version:
React component version of filerobot video editor (FVE).
1 lines • 2.03 kB
JavaScript
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{TOOLS_IDS}from"../utils/constants";import useStore from"./useStore";import useAnnotation from"./useAnnotation";var ADDED_IMG_SPACING_PERCENT=.15,useImageScaled=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:ADDED_IMG_SPACING_PERCENT,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=useStore(),e=d.originalSource,f=d.shownImageDimensions,g=d.adjustments.crop,h=void 0===g?{}:g,i=useAnnotation(_objectSpread({name:TOOLS_IDS.IMAGE,opacity:1},b),_objectSpread({enablePreview:!1},c)),j=_slicedToArray(i,3),k=j[0],l=j[1],m=j[2],n=function(b,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},g=h.width/f.originalSourceInitialScale||e.width,i=h.height/f.originalSourceInitialScale||e.height,j=h.x/f.originalSourceInitialScale||0,k=h.y/f.originalSourceInitialScale||0,l=Math.min(1,g/(b.width+b.width*a),i/(b.height+b.height*a)),m=_objectSpread({name:TOOLS_IDS.IMAGE,image:b,x:j+g/2-b.width*l/2,y:k+i/2-b.height*l/2,width:b.width*l,height:b.height*l},d);return c(m),m};return{image:k,saveImage:l,addImgScaled:function(a,b){n(a,m,b)},updateImageScaled:function(a,b){var c=n(a,l,_objectSpread(_objectSpread({},b),{},{originalImage:a}));return c}}};export default useImageScaled;