Giter VIP home page Giter VIP logo

vue-free-transform's Introduction

VueJS Free Transform Tool

NPM Version NPM Downloads License: MIT Build Status

VueJS component for resizing, dragging and rotating html elements using css transform matrix

VueJS free transform tool

Installation

yarn install vue-free-transform or npm install vue-free-transform --save

Demo

https://codesandbox.io/s/1jl7z9p3q

Usage

import FreeTransform from 'vue-free-transform'
  
<FreeTransform 
    :x="0"
    :y="0"
    :scale-x="1"
    :scale-y="1"
    :width="100"
    :height="100"
    :angle="0"
    :offset-x="0"
    :offset-y="0"
    @update="update($event)"
>
    <div class="element" :style="{width: `100px`,height: `100px`}">
        <img src="..."/>
    </div>

</FreeTransform>

Optional Attributes

selected selectOn styles

Attribute Description
styles additional styles for parent wrapper usefull for z-index
selected hide the controls when values is false
selectOn trigger selection on mousedown, click or dblclick
aspect-ratio enable aspect ratio resizing default (true)
scale-from-center enable scale from center resizing default (true)

Events

onSelect dblclick click mousedown

css

    
    .tr-transform--active{
        position: absolute;
        z-index: 5;
    }
    
    .tr-transform__content{
        user-select: none;
    }
    .tr-transform__rotator {
        top: -45px;
        left: calc(50% - 7px);
    }

    .tr-transform__rotator,
    .tr-transform__scale-point {
        background: #fff;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        position: absolute;
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(0, 0, 0, 0.1);
        cursor: pointer;
    }

    .tr-transform__rotator:hover,
    .tr-transform__scale-point:hover {
        background: #F1F5F8;
    }

    .tr-transform__rotator:active,
    .tr-transform__scale-point:active {
        background: #DAE1E7;
    }

    .tr-transform__scale-point {

    }

    .tr-transform__scale-point--tl {
        top: -7px;
        left: -7px;
    }

    .tr-transform__scale-point--ml {
        top: calc(50% - 7px);
        left: -7px;
    }

    .tr-transform__scale-point--tr {
        left: calc(100% - 7px);
        top: -7px;
    }

    .tr-transform__scale-point--tm {
        left: calc(50% - 7px);
        top: -7px;
    }

    .tr-transform__scale-point--mr {
        left: calc(100% - 7px);
        top: calc(50% - 7px);
    }

    .tr-transform__scale-point--bl {
        left: -7px;
        top: calc(100% - 7px);
    }

    .tr-transform__scale-point--bm {
        left: calc(50% - 7px);
        top: calc(100% - 7px);
    }

    .tr-transform__scale-point--br {
        left: calc(100% - 7px);
        top: calc(100% - 7px);
    }

Keyboard shortcuts

shift for aspect ratio resizing

alt for scaling from center

shift + alt scaling from center based on aspect ratio

shift while rotation will snap rotation using 15 degrees

vue-free-transform's People

Contributors

breakintheweb avatar skmail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-free-transform's Issues

Why does scaling effect the "x", "y"

Hi

first of all, this plugin seems very nice, but I don't understand what happens when you scale the object with the scale handlers.

It seems that inside the payload object returned by the update event the x and y attribute changes as well even if you use the right bottom handler.

It seems to me this should only be the case if the top corner changes it's position (as I understand that that is what "x" and "y" is.

I forked your example and added some logging: https://codesandbox.io/s/l49ryyjjom

Am I misunderstanding what is going on?

restricting transformable area

Hi.

Vue-free-transform is great. Translatable area restriction capability make it better, I guess. In many cases, area restriction is useful. Without it, translation is so free that object can be released in a area where horizontal position is negative and selection is impossible.

I found that the restriction is possible by checking payload in update(). But it looks much better to have certain component's property for restriction.

Draggable Clone

Can I make a draggable clone when drop it in a droppable? (Look like widget system of Wordpress)

Thank you!

Z-Index

Any plans to make the z-index configurable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.