-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zoom feature. #95
Comments
that kinda sucks :D I am just done adding the image editor to my project and this feature is kinda mandatory... should have probably done my research |
I need too |
You can try this hack:
Run this after image editor initialization. This example for mouse wheel, but you also can implement this for buttons. To prevent image jumping issue required to override top position of .tui-image-editor.
|
it's not working |
try this
and add this method below
|
yes
This is working fine but i am not able to move the image after zooming the
image
Thank you..
…On Fri, Nov 22, 2019 at 2:25 PM Cocoroise ***@***.***> wrote:
try this
add this in constructor in graphics.js
onMouseWheel: this._onMouseWheel.bind(this),
and add this method
_onMouseWheel(fEvent) {
const delta = fEvent.e.deltaY / 1000;
let zoom = this._canvas.getZoom();
zoom = zoom + delta;
if (zoom > 5) {
zoom = 5;
}
if (zoom < 1) {
zoom = 1;
}
this._canvas.setZoom(zoom);
// update vptCoords
this._canvas.calcViewportBoundaries();
fEvent.e.preventDefault();
fEvent.e.stopPropagation();
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#95?email_source=notifications&email_token=AL4VRXZB422EDPCOEK3WENTQU6M7DA5CNFSM4GFIKI7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE47YOY#issuecomment-557448251>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4VRX33N7AWUJKGMQUNQDDQU6M7DANCNFSM4GFIKI7A>
.
|
if you want to move the canvas you should add new feature,fabric dont implement this. In my code,i add a _onFabricMouseMove(fEvent) {
const canvas = this.getCanvas();
if (this.isDragging) {
// eslint-disable-next-line prefer-destructuring
const e = fEvent.e;
const vpt = canvas.viewportTransform;
const zoom = canvas.getZoom();
const offsetX = e.clientX - this.lastPosX;
const offsetY = e.clientY - this.lastPosY;
// viewportTransform 4/5 is the offset position
vpt[4] += offsetX;
vpt[5] += offsetY;
const width = canvas.getWidth();
const height = canvas.getHeight();
// limit the canvas
if (vpt[4] >= 0) {
vpt[4] = 0;
} else if (vpt[4] <= width - width * zoom) {
vpt[4] = width - width * zoom;
}
if (vpt[5] >= 0) {
vpt[5] = 0;
} else if (vpt[5] <= height - height * zoom) {
vpt[5] = height - height * zoom;
}
canvas.renderAll();
this.lastPosX = e.clientX;
this.lastPosY = e.clientY;
}
} |
I had to create a Fork to address Zoom and Pan. Hope this helps. |
@sabinayakc looks good, could you open a Pull-Request with that? |
@sabinayakc what's up ? |
You can also check this repo: https://github.com/bradstiff/react-responsive-pinch-zoom-pan, to allow pinch zoom with mobile and touch devices |
@sabinayakc did you create a pull request? It would be great to have zoom and pan added in! |
I think he hadnt yet. But I forked his fork https://github.com/Amerlander/tui.image-editor and wrote about my implementation in a PR here sabinayakc#1. Maybe it is helpfull in some way. The PR is marked as Merged, but it was reverted later as you can see in the last comment. |
@Amerlander , @mattStayner , @marioviana - If you guys wanna be a collaborator and make changes to the forked repo please let me know. I can add you all. Been very busy in my professional life so haven't had a time to catch up. |
Pan and Zoom using mouse gestures: No changes in sources, i use a separete class: Only need: call new IEditorPanZoom(imageEditor).enable(); I haven't tested it on iPhone yet ...
|
@ricardojlrufino did you provided touch mobile compatibility ? example: https://github.com/prc5/react-zoom-pan-pinch |
Only Zoom for mobile ! PAN need custom user option to work together with object selection. |
Version
tui-image-editor.js 3.2.1
Development Environment
Chrome, Windows, AngularJS
Current Behavior
No zoom feature.
Expected Behavior
My image is quite large and when previewing on tui editor, it looks pixelated, it would be a good feature to have zoom for images have texts to make them readable.
The text was updated successfully, but these errors were encountered: