Comments (11)
Hey, @R-W-C
The works on v2 has come to the end.
I will try my best to release beta version this month!
from zoomist.
Hi @ESPRI-Paula ,
Thanks for your like! Actually, I'm working on new library Zoomist v2. I'll take your advice in v2.
from zoomist.
@trehoffman Thanks for your help! I already figured out a better solution to rotate image and implemented it for the next version. I'll publish it ASAP!
from zoomist.
hey @MRoseBCC
Because zoomist works based on css transform, it will clear your css transform when updates.
I figure out a bad way can probably solve your problem.
try this following code
const ele = document.querySelector('#my-zoomist')
new Zoomist(ele, {
on: {
ready() {
const img = ele.querySelector('.zoomist-image')
const wrapper = ele.querySelector('.zoomist-wrapper')
const inner = document.querySelector('div')
inner.classList.add('zoomist-inner')
wrapper.append(inner)
inner.append(img)
}
}
})
and use CSS position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform: rotate(90deg);
to .zoomist-inner
from zoomist.
Hi @cotton123236 ,
I really like your work (thank you), but I had to add the options rotate on a short time (seems easier than to find another lib).
If you plan to add it, maybe it can help :
Adding rotate to options :
var DEFAULT_OPTIONS = {
[...]
// {Number} the degre of the rotation
rotate: 0,
};
In zoom(zoomRatio, pointer) {}
const angle = options.rotate * (Math.PI / 180);
const cos = Math.round(Math.cos(angle));
const sin = Math.round(Math.sin(angle));
const rotatedX = transformX * cos + transformY * sin;
const rotatedY = -transformX * sin + transformY * cos;
const newData = {
width: newWidth,
height: newHeight,
left: newLeft,
top: newTop
};
setObject(data.imageData, newData);
setStyle(image, { ...newData,
transform: `rotate(${options.rotate}deg) translate(${rotatedX}px, ${rotatedY}px)`
});
In dragMove
const calcTransX = pageX - dragData.startX + dragData.transX;
const calcTransY = pageY - dragData.startY + dragData.transY;
const angle = options.rotate * (Math.PI / 180);
const cos = Math.round(Math.cos(angle));
const sin = Math.round(Math.sin(angle));
const rotatedX = calcTransX * cos + calcTransY * sin;
const rotatedY = -calcTransX * sin + calcTransY * cos;
const transformX = roundToTwo(rotatedX);
const transformY = roundToTwo(rotatedY);
image.style.transform = `rotate(${options.rotate}deg) translate(${transformX}px, ${transformY}px)`;
rotate(${options.rotate}deg)
has to be added to every image.style.transform and setStyle change too...
It may needs to be perfected but I hope it helps someone.
from zoomist.
Hello Cotton,
Any idea when v2 gonna be released?
And thank you for creating this great viewer 👍
from zoomist.
I opened a Pull Request to integrate rotation functionality, but looks like you might already have implemented it for the next version!
from zoomist.
Hi @R-W-C @trehoffman @ESPRI-Paula ,
Sorry for the wait! I rebuild Zoomist with TypeScript and already published on NPM just few days ago.
You can checkout branch next. Now you can zoom any element not just image, so you can do anything you want inside .zoomist-image
, includes rotate <img/>
! I'll set v2 to default version after I build the documentation.
If you have any question or suggestion for Zoomist version 2, please let me know! Thanks!!
from zoomist.
@cotton123236 I tried out the new branch, but the rotate button is disabled initially. It becomes enabled when I zoom, but clicking it only resets the image back to inital zoom state and doesn't rotate the image.
from zoomist.
Hi @trehoffman ,
That is actually a reset button instead of a rotate button. The purpose of Zoomist is to "zoom" images or elements, so it may not be added a rotate button or methods.
But you can custom your own rotate button with version 2.X, for example:
<!-- html -->
<div class="zoomist-container">
<div class="zoomist-wrapper">
<div class="zoomist-image">
<img class="my-image" src="..." />
</div>
</div>
</div>
<button class="rotate-btn" role="button">ROTATE</button>
<!-- js -->
<script>
let imageRotation = 0
const image = document.querySelector('.my-image')
const rotateBtn = document.querySelector('.rotate-btn')
rotateBtn.addEventListener('click', () => {
imageRotation += (imageRotation >= 270 ? - 270 : 90)
image.style.setProperty('transform', `rotate(${imageRotation}deg)`)
})
</script>
Hope this comment helps you!
from zoomist.
How to keep image dimensions after device rotation?
from zoomist.
Related Issues (20)
- Add accessibility to Zoom buttons HOT 2
- Zoomist in slideshow UIKit
- How to stop shrinking with the mouse wheel at the initial size. You can now use the mouse wheel to shrink an image to a point.
- Reset button HOT 1
- image sometimes load as 0px by 0px, white blank background HOT 2
- Set zoom focal point HOT 1
- React NextJS: external CSS error HOT 4
- Horizontal scroll breaks zoom
- error HOT 4
- Zoomist v2.0 does not work HOT 2
- Not working on Desktop Safari
- Can it be used inside a div element? Does it have to be only for scaling images? HOT 2
- Zoomend event HOT 1
- Maybe touch-action:none; only after first Zoom Event ? HOT 1
- please help on not found element issue HOT 1
- why can't I click on the button inside the zoomist-image container? HOT 2
- Zoomer buttons cause a form submition HOT 1
- Issue with Angular v17 HOT 1
- Unable to resolve path to module 'zoomist/css'. HOT 1
- Trying to get the Image base64 encoded that is the result of the zoom and transform HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zoomist.